How to redirect with query string in Nginx
6,038
But the q parameter is empty on redirection.
I don't see that problem. When I test the configuration as written, it creates a redirection loop because the original keywords='value'
is appended to the rewritten URI.
You can prevent rewrite
from including any original parameters by appending a ?
to the rewritten URI.
For example:
rewrite ^ /search?q=$arg_keywords? permanent;
See this document for details.
Author by
Ordidaad
Updated on September 18, 2022Comments
-
Ordidaad almost 2 years
I would like to redirect:
something.com/search?keywords='value'
to
something.com/search?q='value'
Here is my Nginx config:
location ~ /search { if ($args ~* "keywords=(.*)") { rewrite ^.*$ /search?q=$arg_keywords permanent; } }
But the
q
parameter is empty on redirection.What is wrong?