I am trying to redirect some URLs which have query string. My problem is that Nginx regex ignores question mark in the URLs, so my regex fails matching if there is a question mark in middle of URLs.
something like this:
/product/list/mfr/%D9%86%D9%88%DA%A9%DB%8C%D8%A7-nokia?inc_subs=1&manufacturer_id=25&page=6
redirect to this URL:
/product/list/69_70_80/nokia-mobile
I tried:
map $uri $new_uri {
~^/(product/list/mfr)/ /product/list/69_70_80/nokia-mobile
}
it works but it's not accurate because I have other URLs that will match with this regex which I don't want.
I also tried this:
location ~/product/list/mfr/(\S+)page=6$ {
return 301 https://www.example.com/product/list/69_70_80/nokia-mobile;
}
regex101 says it matches, but when I try in browser it does not redirect. The only character that ruins it is the question mark. If I only delete the question mark, it works!!
regex101 link: https://regex101.com/r/UvXZF0/1/
It's been hell of a problem and headache, I really appreciate it if anybody can solve it