【发布时间】:2019-03-14 15:06:49
【问题描述】:
当我重构我的网站时,我在 .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;
}
【问题讨论】:
标签: regex nginx url-rewriting processing-efficiency