19 januari, 2011
Setup a ”Down for Maintenance” page for your website
If you host a website, sooner or later you will probably have to do some maintenance work. Perhaps you need to upgrade it, deploy a new major version or move it to a new server. In order to prevent your visitors from reaching the site during the maintenance time you can take it offline, but you don’t want them to see an ugly error page.
Instead you should create an informative and beautiful maintenance page, that apologize for the inconvenience and inform about when the site will be back up again.
A simple technique is to use the .htaccess file to redirect to the maintenance page. You will need to verify that everything has gone smoothly after you are done with the maintenance before you let the visitors back in. This can be done by allowing your own IP address to reach the site even during the maintenance downtime.
Here is the .htaccess snippet:
RewriteCond %{REMOTE_ADDR} !^123\.45\.67\.89
RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]
RewriteRule .* /maintenance.html [R=302,L]
Put the .htaccess and your maintenance.html file in the webroot.
Be sure to edit the IP address, if you don’t know your own IP you can look it up at WhatIsMyIp.com
If you are using Silverstripe you can put the above lines at the top of your ordinary .htaccess file.
When you are done with the maintenance work and the site is working again you put it online either by removing the above lines from the .htaccess or simply put a # at the start of each line in order to disable them.
Smashing Magazine have a post about Effective Maintenance Pages, here are the bullet points:
- Keep you maintenance pages simple and useful.
- Realize it’s an inconvenience to your visitors.
- Don’t be afraid to use humor.
- Give your maintenance page the same look and feel as your regular site.
- Let visitors know when your site will be back.
- Provide recommended content.
- Invite your visitors to come back when the site is online again
- Inform your visitors about the progress of the maintenance
The full article can give you some inspiration on creating your maintenance page.