Friday, April 2, 2010

Creating maintenance page for apache

Sometimes we have to put our sites into maintenance mode for any reason, below is the easy way to do it for apache server in centos server.

1. Create a directory named err/ in the root directory. Lets say the site is called foo.bar
# cd /var/www/html/foo.bar
# mkdir err

2. Create a file named 503.html in the err directory
# cd /var/www/html/foo.bar/err
# touch 503.html

3. Put maintenance message into 503.html (this is an example, you can put whatever message you want, and you can put any name for the file :))
# echo "<html><b>This site is currently under maintenance. Thank you</b></html>" > 503.html

4. Add below lines to your virtual host setting for foo.bar


ErrorDocument 503 /err/503.html
## uncomment below to enter maintenance mode
RedirectMatch 503 ^/(?!err/)


5. Restart apache server
# httpd -k graceful

6. Test the website :)

1 comment:

Anonymous said...

Thanks a lot. Very ..very helpful.

Just that redirect did the trick.

Everyone made it seem so simple but nothing was working for me !!!