简体   繁体   English

如何在nginx中将任何URI重定向到不区分大小写的URI

[英]how to redirect any URI to case insensitive URI in nginx

I want to redirect any sensitive URI to case-insensitive in nginx server. 我想将任何敏感的URI重定向到nginx服务器中的不区分大小写的。 For Ex. 对于前 www.doamin.com/foobar or www.doamin.com/FooBar or www.doamin.com/foobar或www.doamin.com/FooBar或
www.doamin.com/FOOBAR or www.doamin.com/fooBAR should be redirected to www.doamin.com/foobar ie, whatever the URI user enter, it should be redirect to its lower-case. www.doamin.com/FOOBAR或www.doamin.com/fooBAR应该重定向到www.doamin.com/foobar,即,无论URI用户输入什么,都应将其重定向到小写字母。

Is there anyone faced this requirement, please help! 有没有人遇到这个要求,请帮忙!

location ~* ^/foobar {
    rewrite (?i)^/foobar /foobar break;
}

and if foobar is a path,you can try this 如果foobar是路径,则可以尝试

location ~* ^/foobar {
    rewrite (?i)^/foobar(.*) /foobar$1 break;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM