How To Put Site Into Maintenance Mode

If you are using the Apache server, you can use.htaccess to control access of the directories within the server, and send a response code of the server status.
To put the website into maintenance mode, you can use the 503 status code, which indicates that the server is temporarily unavailable.
Before we specify anything in .htaccess, however, we need to create a new file in.html or .php format, and add a message in the file, e.g.
Sorry we are down for maintenance, but we’ll be back up shortly.
Style your page. Next, open the .htaccess file in your server, and add the following:

1. <IfModule mod_rewrite.c>
2. RewriteEngine on
3. RewriteCond %{REMOTE_ADDR} !^123\.456\.789\.000
4. RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]
5. RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
6. RewriteRule .* /maintenance.html [R=503,L]
7. </IfModule>

This will set the server status code to 503, while also redirects visitors to the maintenance page. You can set your IP address with the following line RewriteCond %{REMOTE_ADDR} !^123\.456\.789\.000 so that you will still be able to access your website.