To set up a redirect (forwarding) from one domain to another via the nginx web server - let's add the following lines to the configuration file, in the domain settings section:
server {
...
listen IP:80;
server_name source_domain.ru;
rewrite ^ http://target_domain.ru$request_uri;
...
}
or another method (using location):
server {
...
listen IP:80;
server_name source_domain.ru;
location = / { rewrite ^ http://target_domain.ru/; }
...
}
here, instead of source_domain.ru, substitute the name of the domain to redirect from, and instead of target_domain.ru - the name of the domain to redirect to.
Applies to: nginx
Comments