Answer the question
In order to leave comments, you need to log in
Redirect or alias - how to redirect from one domain to another?
Greetings. There are two identical domains in different .ru and .com zones - you need to redirect from .com to .ru
The site in the .ru zone is working, and .com as an alias to it
How will it be kosher to make a redirect?
Previously, under Apache in .htaccess there was an entry Redirect 301 / site.ru
Now the nginx web server.
Answer the question
In order to leave comments, you need to log in
A redirect is when you are redirected to another URL when you try to access the desired domain. In nginx it's better to do it like this:
server {
listen 80; #или гдетамувас
server_name site.com;
return 301 $scheme://$http_host$request_uri;
}
server_name site.com site.ru;
And the rest of the configuration as usual.
In the config for site.com:
location / {
rewrite ^/(.+)$ http://site.ru/$1 permanent;
}
those. is it better to solve such a problem on the side of the web server, and not with an NS CNAME record?
and what is the difference between your variant and these two:
server {
server_name site.com;
rewrite ^/(.*)$ site.ru/$1 permanent;
}
server {
server_name site.com;
return 301 $scheme://site.ru$request_uri;
}
so no one answered ...
what method and how will it affect the search position of the site?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question