Javeline / Ajax.org, Life as a hoster, PHP
How I PHP: How to take a website offline.
I’ve seen a lot of methods used to take a website temporarily off-line for maintenance. Most involve a using PHP to disable the site or renaming the index file. There is however a far better method of doing this, by placing the following in the vhost file or in an .htaccess file in the document root:
Header always set Retry-After "Thu, 18 Jun 2009 08:00:00 +0200" Redirect 503 /
This way you are sure no part of the site is used. Also by returning a 503 http response, search-engine crawlers will not reindex your site right at the moment it is down. You can use ‘ErrorDocument’ to place a different text than the apache default.
17 Jun 2009 Arnold Daniels





That’s polite, especially compared to my usual rude and brutish “deny from all”.
Seconded. It make a nice change to meet someone who understands HTTP.
Of course, it would be even nicer not to take a website offline in the first place, and it’s usually avoidable with some planning
The thing I’d add to this though, would be that when sending a 503 it might be considered polite to also send a Retry-After header, which will give the client some idea of when the site/service will be back up.
That is be a nice addition Simon. I’ve changed the example accordingly.
lol, as if someone was still using Apache.
What are you talking about Jesus? Almost half of all websites run on Apache. See http://news.netcraft.com/archives/2009/06/17/june_2009_web_server_survey.html
If you have a similar solution for another webserver like Lighttpd, please add a comment supplying the comment.