Display a Site Maintenance Page Using .htaccess and mod_rewrite

Have you ever wanted to display a maintenance page to all of the visitors to your site, whilst still being able to view it as normal yourself?

This small snippet will do just that, as the title suggests it requires a .htaccess file and mod_rewrite so it’ll only work with Apache servers that have the mod_rewrite module enabled.

The above code will send all user requests to the maintenance.html file apart from those sent from the 111.111.111.111 IP address. The redirect is carried out with a 503 Service Unavailable header so that search engines will know to come back later rather than attempt to index the contents of the maintenance page.

Just change the IP address (111\.111\.111\.111) to match your own. If you require access from more hosts then just duplicate RewriteCond %{REMOTE_ADDR} !^111\.111\.111\.111 as many times as required and replace the IP address.

Easy!