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

cat <<EOF
Status: 503
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<title>503 - Service temporary unavailable</title>
<h1>503 - Service temporary unavailable</h1>
<p>Sorry, this website is currently down for maintainance please
retry in a few minutes</p>

Then add this to your virtual host config and reload Apache:

  ScriptAlias /  /path/to/your/

Please note the trailing slash! It's needed!