Hosting a Downtime Page with Apache

I had to help set up a downtime page for a site experiencing an extended outage. We wanted a “We’re working on it!” type page to let people know what it would be back up soon. But the problem is that if you serve this as a static HTML page, it would (a) only work on the site’s root page, and (b) be served with an HTTP 200 status code, potentially getting crawled by search engines and ending up in peoples’ caches. Both of those are bad.

What I really wanted was to set an HTTP status code that indicated that there was an error condition, so that browsers would hopefully not cache the page, and so that search engines would know not to index the page contents. HTTP 503 works perfectly for this — “Service Unavailable.”

I ended up setting up a new Apache virtual host on my existing server (not the one that’s down, of course), creating a quick page named downtime.html (the only content), and throwing together the .htaccess (assembled piecemeal from some reference sites, admittedly):

RewriteCond %{ENV:REDIRECT_STATUS} !=503
RewriteRule !^/downtime.html$ /downtime.html [L,R=503]
ErrorDocument 503 /downtime.html

The result is that all pages on the site now get the downtime page in response, served with the appropriate HTTP status code. Ta-da! This isn’t anything terribly involved, of course, but figuring out how to set a 503 via mod_rewrite was quite confounding.

One thought on “Hosting a Downtime Page with Apache

  1. So, it is REALLY a server problem? Very difficult to believe after so many days of being left in an information vacuum, & checking the current employment status of key personnel… Are you the “wonderful subcontractor” or the “1/2 person” referred to on the latest FB update?

    But if you say it is, for a fact, the servers (what?? No redundancy, no co-location? Really??!!), then I’ll believe you.

    As always, I wish you the best, Matt ~

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    Markdown is turned off in code blocks:
     [This is not a link](

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see