How-to Put Your Site In Maintenance Mode Using .htaccess
I need to put my websites into maintenance mode sometimes and found a handy little script .htaccess definition on Webmastersworld.com. It lets everyone know via a customised error document message that the site is currently unavailable.
The neat thing is that is blocks access to everyone but me and gives people and bots alike a status message that won’t put them off (unless you choose to of course).
Order Deny,Allow
Deny from all
Allow from my.ip.address
Allow from all
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^([^.]*)\.html?$ /$1.php [T=application/x-httpd-php,L]
ErrorDocument 403 /403.txtThe first part disallows access to everything for everyone but me. Make sure you replace my.ip.address with your current WAN IP. To find this out you can either go to www.whatsmyip.org or use [url=https://addons.mozilla.org/extensions/moreinfo.php?id=1254&application=firefox]the handy plug-in for Firefox[/url] which will tell you your current external IP.
The second part will only allow our custom error page to show up to everyone (but me). If you prefer an HTML instead of my quick-n-dirty text-only, make sure to change the extension to .html or .htm. PHP or any other webserver readable extension will work of course.
The third part will call our custom error message in form of a text file. Make sure you point it to the path where your error document resides! If you want to make a subdirectory of your domain unavailable (i.e. www.segebrecht.com/lydia) and the doc is in that directory, use /lydia/403.txt !
All you need to do is to knock up a simple file (text or html, or whatever) and put your message in ![]()
Then change your htaccess to the above code, upload your error document and voila – a custom “maintenance” message.
To check it’s actually working, just comment out (using #) the Allow from my.ip.address part and hit reload in your browser. If you can see your custom message you are set.
Have fun and remember that I do not take any responsibility in case anything goes wrong ![]()
Thanks to Google for helping me find the gem and “lorax” of webmastersworld.com for coming up with the item in the first place.
Ref: http://www.webmasterworld.com/forum92/2458.htm
Technorati Tags: htaccess | websites

Leave a Comment