Answer the question
In order to leave comments, you need to log in
How to make a redirect in NGINX with parameters?
There is a mobile version of the site located on the subdomain m.site.ru
Desktop, respectively, on site.ru It is
necessary to make a 301 redirect from the mobile version to the desktop.
The section has the address https://m.site.ru/read/X, where X is the article number, there are many articles.
I don’t understand how to make a rule so that there is automatically a 301 redirect both from
https://m.site.ru/read to https://site.ru/read
and from https://m.site.ru/read/ X to https://site.ru/read/X
There is a
simple redirect from m.site.ru/read -> site.ru/read. It remains to improve this rule so that the redirect works on article numbers as well
location = /read {
return 301 https://site.ru/read;
}
Answer the question
In order to leave comments, you need to log in
location = /read {
return 301 https://site.ru/read$request_uri;
}
You need to remove the equal sign, this is how it should work:
location /read {
return 301 https://site.ru$request_uri;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question