Redirect Nginx永久重定向,带和不带尾部斜杠
我找不到任何方法使带有或不带有尾部斜杠的url重定向正常工作 每当调用Redirect Nginx永久重定向,带和不带尾部斜杠,redirect,url-rewriting,nginx,rewrite,Redirect,Url Rewriting,Nginx,Rewrite,我找不到任何方法使带有或不带有尾部斜杠的url重定向正常工作 每当调用example.com/info和example.com/info/的url将转到example.com/info page/,并在url后面添加“-page”字符串时,我都想这样做 location /info/ { rewrite ^(/info)(.*)$ http://example.com/$1-page/ permanent; } 我如何才能做到这一点?您不需要位置,只需使用: rewrite ^/in
example.com/info
和example.com/info/
的url将转到example.com/info page/
,并在url后面添加“-page”字符串时,我都想这样做
location /info/ {
rewrite ^(/info)(.*)$ http://example.com/$1-page/ permanent;
}
我如何才能做到这一点?您不需要
位置
,只需使用:
rewrite ^/info/?$ http://$host/info-page/ permanent;
或
解决了我的问题。谢谢:)
if ($request_uri !~ "^/info/?$")
{
return 301 http://$host/info-page/;
}