当我重构我的站点时,我在.htaccess中有一堆重定向。现在我想为nginx重新创建它们。以下是等价物,哪种风格更有效?
# Style A
location / {
location /foo/123/old {
rewrite ^(.*) /bar/123/ permanent;
}
location /baz/456/old {
rewrite ^(.*) /bar/456/ permanent;
}
}
# Style B
location / {
rewrite ^/foo/123/old\/?$ /bar/123/ permanent;
rewrite ^/baz/456/old/\/?$ /bar/456/ permanent;
}
发布于 2018-10-10 03:25:42
根据nginx
自己的建议,您应该使用location块和return
指令
https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/#taxing-rewrites
https://stackoverflow.com/questions/52727765
复制相似问题