Currently I have something like this in my nginx.conf file:
location ~ /old/page/?$ {
return 301 /new-page;
}
The issue is that query strings are being stripped from the /old/page?ref=xx URL.
Is it possible to include query strings using the redirect method I'm using above?
Anything from the
?
and after is the query string and is not part of the normalised URI used inlocation
andrewrite
directives. See this document for details.If you want to keep the query string, either add it to the
return
:Or with
rewrite
, the query string is automatically appended unless a?
is added:See this document for location syntax, and this document for return/rewrite.