0

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

1 Answer 1

2

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.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.