Sometimes I need to stop my website to put it under maintenance and I use the following NGINX configuration:
server {
server_name mypage.com;
listen 443 ssl http2;
listen [::]:443 ssl http2;
root /var/www/mypage.com/public_html/;
index maintenance.html;
}
The question is, if I access my website as follows:
https://mypage.com
everything works correctly and the maintenance.html page that I want is displayed.
The problem is when someone accesses a page within my site that is NOT the main one (for example, https://mypage.com/contact), which causes a page not found error.
What I want to achieve is that, in maintenance mode, any visitor of my web, accessing any subpage of it, arrives to the maintenance.html page.
Thanks!
Adding this in inside the server block should do it, it will always match this location unless a more precise one is declared.