Maintenance Page - Service Unavailable

If you need to shut down your web site for maintenance it will be helpful to be prepared with an informative status page.

What we have to setup:

  1. a web site to inform your visitors what is going on
  2. the proper webserver rules to redirect traffic to the maintenanace page

A Maintenance or Service Unavailabe Page Template

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 
<html>
<head>
  <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
  <!-- we don't want this page to be cached -->
  <meta http-equiv="cache-control" content="no-cache">
  <!-- we don't want this page to be indexed by a search engine -->
  <meta name="robots" content="noindex" />
  <title>503 Service Unavailable </title>
  <style>
  body {
    font-family: arial, helvetica, sans-serif;
    font-size: 14px;
    bgcolor: "#ffffff";
    text-align: center;
  }
 
  h1 {
    font-size: 2em;
  }
  a {
    text-decoration: none;
  }
  </style>
</head>
 
<body>
 <h1>503 Service Unavailable</h1>
 <p></p>
 <p>Our website is down at the moment.</p>
 <p>We apologize for any inconvenience.</p>
 <p>We expect to be back again within a few minutes.</p> </p>
</body>
</html>

Further reading:

Rewrite Rules to Activate the Maintenance Page

Place a .htaccess file in your docroot with the following contents:

RewriteEngine On
 
# Optional: disable maintenace page for your own IP address:
#RewriteCond %{REMOTE_ADDR} !xxx.xxx.xxx.xxx
#RewriteCond %{REMOTE_ADDR} ![2001:0DB8::12]
 
# maintenance page must exist
RewriteCond %{DOCUMENT_ROOT}/503.htm -f
 
# only if this file exists, too, rewrite will happen:
# doesn't need any content
RewriteCond %{DOCUMENT_ROOT}/503.enable -f
 
# prevent an endless loop
RewriteCond %{SCRIPT_FILENAME} !503.htm
 
# rewrite everything to status page
# [R=503] Redirect with status code 503 (service unavailable)
# [L] Last rule, apply ruleset
RewriteRule ^.*$ /503.htm [R=503,L]
 
# define which file is to be served
ErrorDocument 503 /503.htm

If you are on shard hosting, it might not be possible to issue a 5xx error.
What will almost always work (stripping down most functionality) is this:

RewriteEngine On
# prevent an endless loop
RewriteCond %{SCRIPT_FILENAME} !503.htm
 
# rewrite everything to status page
# [R=302] Redirect with status code 302 (found) - The requested resource resides temporarily under a different URI
# [L] Last rule, apply ruleset
RewriteRule ^.*$ /503.htm [R=302,L]

Further reading:

apache/maintenance_page_service_unavailable.txt · Last modified: 2015-09 by tb
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0 ipv6 ready