我只想更改一组页面上 url 的第一部分。
例如。
domain.com/change/this/that/other
到
domain.com/changed/this/that/other
在这个例子中,包括这个在内的所有内容都是动态的
我觉得这行得通
location ~* ^/change/(.*)$ {rewrite ^ http://domain.com/changed/$1 permanent; break;}
但没有
最佳答案
正则表达式捕获变量与重写 block 本身有关。
location ~* ^/change/(.*)$ {
rewrite ^/change/(.*)$ http://example.com/changed/$1 permanent;
break;
}
你可以看到例子:http://nginx.org/en/docs/http/ngx_http_rewrite_module.html
关于redirect - Nginx 重定向仅更改域后 URL 的第一部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32462739/