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 above case ,
www.example.com/WapsiteDataFetch
is redirected properly to http://images.xample.com/xyz/images
however, the url "www.example.com/WAPSITEDATAFETCH"
is not redirected properly.
Even if I Change a single character it is giving 404 error.
I have tried many blogs and seen many post from stack overflow and many of them have suggested "~*" but in my case it is not helping me.
please help me as I am stuck on this for a couple of days.
Use (?i)
to match case-insensitively - http://perldoc.perl.org/perlretut.html
Location block is not necessary. Try this.
rewrite (?i)^/WapsiteDataFetch(.*) http://images.xample.com/xyz/images$1 permanent;
you can avoid using the regex engine twice, by doing the capturing inside the location block
location ~* WapsiteDataFetch(.*) {
return 301 http://images.xample.com/xyz/images$1;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With