Nginx case insensitive

I want to do case-insensitive URL redirection in nginx Below is my code.

location ~* WapsiteDataFetch{
      rewrite  WapsiteDataFetch(.*) http://images.xample.com/xyz/images$1 permanent;
    }

In the case above

www.example.com/WapsiteDataFetchredirects correctly http://images.xample.com/xyz/images however the url is "www.example.com/WAPSITEDATAFETCH"not redirecting properly.

Even if I change one character, it gives a 404 error.

I tried a lot of blogs and saw a lot of posts from, and many of them suggested "~ *", but in my case it does not help me.

Please help me as I am stuck on this a couple of days.

+3
source share
2 answers

Use (?i)for caseless matching - http://perldoc.perl.org/perlretut.html

A location block is not required. Try it.

rewrite (?i)^/WapsiteDataFetch(.*) http://images.xample.com/xyz/images$1 permanent;
+15

,

location ~* WapsiteDataFetch(.*) {
  return 301 http://images.xample.com/xyz/images$1;
}
+2

All Articles