Return 503 Status with Apache
Sometime you want to do some heavy work on a virtual host and don't want anyone access your page. But you can't shut down your whole server and don't want to use any redirects to avoid confusing search engine spiders. Well the correct HTTP status code to return is a 503 - Service temporary unavailable.
To do this create the following shellscript named 503.sh
:
#!/bin/sh cat <<EOF Status: 503 Content-Type: text/html; charset=iso-8859-1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN"> <html> <head> <title>503 - Service temporary unavailable</title> </head> <body> <h1>503 - Service temporary unavailable</h1> <p>Sorry, this website is currently down for maintainance please retry in a few minutes</p> </body> </html> EOF
Then add this to your virtual host config and reload Apache:
ScriptAlias / /path/to/your/503.sh/
Please note the trailing slash! It's needed!