Put site in maintenance mode with .htaccess
Sooner or later you’ll probably run into situation when you will have to put your site in maintenance mode so that you can upgrade your site or move it to a new server or make changes etc. Below is the simplest way to do it using .htaccess if your site is running on Apache.
First create a maintenance page say maintenance.html and put it in your site’s document root (public_html/httpdocs etc.). Now add the below lines to top of your .htaccess file. You can simply create a blank .htaccess file and add lines if .htaccess doesn’t exist in your site’s document root.
RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} !^/maintenance\.html$ RewriteRule ^(.*)$ http://yoursitename.com/maintenance.html [R=307,L]
Sometimes you may want everyone else to see the maintenance page expect yourself. You can simply do it by allowing your IP. You should add the line “RewriteCond %{REMOTE_ADDR} !^xx\.xx\.xx\.xx” after RewriteBase line. Here you should replace xx.xx.xx.xx with your IP address
RewriteEngine On RewriteBase / RewriteCond %{REMOTE_ADDR} !^xx\.xx\.xx\.xx RewriteCond %{REQUEST_URI} !^/maintenance\.html$ RewriteRule ^(.*)$ http://yoursitename.com/maintenance.html [R=307,L]