Answer the question
In order to leave comments, you need to log in
How to set up redirects on nginx?
Hello. I'm trying to set up redirects in such a way that the ?lang=ru get-parameters lead to mysite.com/ru/ or the city page mysite.com/subcat/?lang=ru leads to mysite.com/ru/subcat This way does not work:
location / {
if ($arg_lang = ru) {
return 301 $uri;
}
}
Answer the question
In order to leave comments, you need to log in
The issue was resolved as follows, if you're interested:
if ($request_uri ~* "([^\/]{3,})\?" ){set $last_path_component $1;}
if ($arg_lang){return 301 /$arg_lang/$last_path_component;}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question