Nginx redirect domain name to another domain

Updated: 2 May, 2018 seen 18,810

Redirecting website visitors to a different domain name using Nginx is simple.

Add the following code to your server config: 

server { server_name .domain.com;
return 302 $scheme://forwarded-domain.com;
}

Restart Nginx

sudo /etc/init.d/nginx restart