I'm adding around 30 redirects, 90% of them are straight forward URLs, however there's a few that have query strings e.g.
.com/?page_id=2966
.com/?page_id=2965
.com/?page_id=2964
All the other redirects work fine, however none of these ones work using the following rewrite rule:
rewrite ^/?page_id=2966$ /sustainable-travel? permanent;
rewrite ^/?page_id=2965$ /car-sharing? permanent;
rewrite ^/?page_id=2964$ /eco-driving? permanent;
We've reloaded and restarted the server without any luck - Is there something special we should be doing in a config to capture these?
Thanks
CodePudding user response:
Anything from the ?
and after is the query string and is not part of the normalized URI used in rewrite
(and other) directives.
Typical solutions are using the map
directive to map query string parameters to URIs, or not doing this type of redirection at the Nginx level, and using a plugin like Retour* to handle redirects.
- Disclaimer: I'm the author of Retour.