Answer the question
In order to leave comments, you need to log in
How to make Nginx redirect?
How to make Nginx redirect from site.com/%40user
to site.com/@user
I write the following condition , but there is no redirect. It seems to me that this is because of the % sign , it needs to be escaped somehow, because when I remove it and leave it just 40 , the redirect works for
I tried to look for how to escape % , but there is nothing sensible. Maybe I'm digging in the wrong direction? rewrite ^/%40(.*)$ /@$1 permanent;
rewrite ^/40(.*)$ /@$1 permanent;
site.com/40user
Answer the question
In order to leave comments, you need to log in
location
and rewrite
for matching use the request URI in a normalized form, i.e. already after decoding the text given in the form %XX
.
In its original form, the request can be found in $request_uri
. There it will be entirely (with arguments).
if ($request_uri ~ "^/%40(.*)$") {
return 301 /@$1;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question