我正在尝试将所有访问 URL“ http://example.com/something ”的用户重定向到像“ http://answares.com/examples_com/something ”这样的 URL 。
我正在尝试使用这样的代码:
server {
listen 1.2.3.4:80;
server_name "example.com";
rewrite ^(.*) http://answares.com/examples_com$1 permanent;
}
Run Code Online (Sandbox Code Playgroud)
通过访问“ http://example.com/ ”我被重定向到“ http://answares.com/examples_com/ ”,但是通过访问“ http://example.com/something ”我被重定向到:“ http ://answares.com/something ”。
我尝试以不同的方式做到这一点,但我得到的最好的是:
http://answares.com/examples_com//something
Run Code Online (Sandbox Code Playgroud)
因为这两个斜线看起来很蹩脚。我在 Ubuntu 10.4 上使用 Nginx 0.7.65