Answer the question
In order to leave comments, you need to log in
How to make a redirect from the main directory to the directory?
We set the task to make a redirect from one site to another. Only domains should change in addresses, but the main of the current site should redirect to a specific directory of the new site.
The config turned out like this:
server {
listen 80;
server_name www.site.ru, site.ru;
location = / {
return 301 http://other-site.ru/newhome; # 301-redirect
# или
#rewrite ^ http://other-site.ru/newhome permanent; # 301-redirect
}
location / {
rewrite ^ $scheme://other-site.ru$request_uri? permanent; #301-redirect
}
}
Answer the question
In order to leave comments, you need to log in
You are correct.
If something is wrong, the problem is most likely in the browser cache.
rewrite ^ $scheme://other-site.ru$request_uri? permanent; #301-redirect
Here ? not needed
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question