Skip to content Skip to sidebar Skip to footer

Redirecting NGINX Domain From One To Another

For example, let's say we are developing several server and now we want to maintenance it.
the visitor will be confused if we directing it without the notice of maintenance. This can be done by doing nginx rewrite from actual domain to maintenance domain.

Then, how we redirect it?

open you nginx server block by typing :

nano /etc/nginx/sites-enabled/your-server-block-name
and add the bolded line below your server_name :

server { server_name;
rewrite ^$request_uri? permanent;

This will temporarily redirect your website to maintenance page