If you or your web hosting service provider works on your Apache based website for anything more than a few seconds, you should put up a message indicating to your visitors that your site is temporarily unavailable and will be back shortly. If you can specify a particular time, even better. It doesn't have to be pretty or fancy but should leave visitors with the impression that there is a site usually there.

You should also set your site to redirect all site URL's, not just the home page. Replacing your index.html, index.htm, default.aspx or index.php is not an option as this will only take care of your home page. A 503 (Service Unavailable) status code should be returned to the browser in the http header regardless of which page they might be going to. This is important to prevent search engines from de-listing your pages and possibly loosing SEO page rankings while the site is down.

If you are using an Apache server, here are a couple of solutions that will enable you to make it happen.

SOLUTION #1 -- .htaccess AND 503.php files

Step 1: Create a generic 503.php page

header("HTTP/1.1 503 Service Temporarily Unavailable");
header("Status: 503 Service Temporarily Unavailable");
header("Retry-After: 3600");
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</a>">
<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>503 - Site upgrade in progress</title>
<meta name="robots" content="none" />
<h1>503 - Site Upgrade in Progress</h1>
<p>The <strong><?php echo $_SERVER["SERVER_NAME"]; ?></strong> website is currently being upgraded and is temporarily not available.</p>
<p>It should be back up and running very soon. Please refresh this page in a few minutes.</p>

You can see the results it produces by visiting www.tngconsulting.ca/503.php. The name of the site will change dynamically depending on the site.

Step 2: Put a directive in your .htaccess file to redirect all pages to your 503.php file regardless of the URL the person is trying to access:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/503.php [NC]
RewriteRule .* /503.php [L]

SOLUTION #2 -- just a .htaccess file (no other file required)

<tt>ErrorDocument 503 "<h1>503-Site Being Upgraded</h1><p>Website is currently being updated and is not available. Refresh in a few minutes.</p>"
RewriteEngine On
RewriteRule .* - [R=503,L]