How To Create A ‘Maintenance’ Holding Page When Upgrading Your WordPress Blog

After much waiting, WordPress 2.7 is finally released. If you have not get your copy of WP 2.7, I urge you to download it now.

maintenance-mode

Before you start to upgrade your existing blog to the latest version of WP, you might want to create a maintenance holding page so that your readers know that your site is temporary down and will resume service in a short time. The last thing that you want to see during upgrading is your site showing a ‘404 error page‘ and all your readers start emailing you to ask what happen.

For basic maintenance/troubleshooting, the Maintenance mode WP plugin works fine to create a Maintenance splash page. But if you are upgrading your WordPress version, the plugin will not work. Here’s a easy way to create a Maintenance holding page that you can use while upgrading to WP2.7.

Creating a Maintenance holding page

Open a text editor. Copy the following code to it and save the file as maintenance.php

<?php
header(“HTTP/1.1 503 Service Temporarily Unavailable”);
header(“Status: 503 Service Temporarily Unavailable”);
header(“Retry-After: 3600″);
?>
<html>
<head>
<title>Site upgrade in progress</title>
<meta name=”robots” content=”none” />
</head>
<body>
<h1>Maintenance Mode</h1>
<p><a title=”Your site” href=”your-site-url”>Your Site name</a> is currently undergoing scheduled maintenance.<br />
Please try back <strong>in 60 minutes</strong>.</p>
<p>Sorry for the inconvenience.</p>
</body>
</html>

If you want to style up your Maintenance page, feel free to do so. The above is only a template that you can use quickly.

Upload it to the parent directory of your site. You’ll need to use a FTP program to upload it. Make sure that the page can be accessed on http://yoursite.com/maintenance.php

Redirecting your readers to the Maintenance page

Next, download your .htaccess file. It is found in the parent directory of your site.

Open it with a text editor. Add the following code to the starting of the page

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !/maintenance.php$
RewriteCond %{REMOTE_HOST} !^127\.0\.0\.1
RewriteRule $ /maintenance.php [R=302,L]

Go to http://www.whatismyip.com and find out the IP address of your network connection.

Replace the 127\.0\.0\.1 with your IP. This will ensure that you still have access to your site while other people are directed to the Maintenance holding page.

Save the .htaccess file. Upload it to your site.  When it prompts you if you want to overwrite, select Yes.

That’s it. When your readers visit your site, they should see something like

maintenance-mode

Note: When you visit your own site, you won’t be able to see the above maintenance page because you have configured your network to allow your IP address.

You can now perform your WordPress upgrade.

Remove the Maintenance holding page

When you are done upgrading your site, you need to remove the redirect so that your readers can access your blog again.

In the .htaccess file, put a # in front of the code that you inserted just now. It should look like

#Options +FollowSymlinks
#RewriteEngine on
#RewriteCond %{REQUEST_URI} !/maintenance.php$
#RewriteCond %{REMOTE_HOST} !^127\.0\.0\.1
#RewriteRule $ /maintenance.php [R=302,L]

Upload it to your site (if prompted whether you want to replace the file, select Yes).

That’s it.

Note:

1) In the future version of WordPress, you may no longer need the Maintenance holding page as there is a feature in WP2.7 that allows you to upgrade your WP right within your dashboard.

2) Although this tutorial is meant for WordPress blog, it will work for any sites and platforms

9 comments

  1. That’s a neat and simple trick and a much needed one at the time of WP 2.7 upgrade. Thanks for sharing this.

  2. Gone are the days of hectic upgrade. Its highly simple to use upgrade plugins if one is on wp2.6…

  3. Great idea – facing a major upgrade process this would be very useful.
    BUT: Where do I go on whatismyip.com to detect my network’s IP address? I don’t know the terms well enough to find the path there…
    Thanks a lot for many great tips
    Kjetil

  4. Thanks,
    It just seemed wrong, with totally different numbers than I expected.
    Ready to upgrade. They say things have happened with WP since 2.6.
    Cheers

  5. Hm – sorry for all these questions, but maybe others have the same problems.
    Now, in the maintenance.php I’ve just replaced the mysite stuff and uploaded it to the site’s root.
    And – to the start of the .htaccess file I’ve added:
    Options +FollowSymlinks
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !/maintenance.php$
    RewriteCond %{REMOTE_HOST} !^62.16.191.158
    RewriteRule $ /maintenance.php [R=302,L]
    but the result to others (and me if I open dolcevita.no/maintenance.php) is
    Parse error: syntax error, unexpected T_LNUMBER in /home/2/d/dolcevita/www/maintenance.php on line 2
    (I also tried to enter the IP address as you had, like 62.16.191.158 – but of course that won’t work.)
    Some obvious mistake?
    Thanks,
    Kjetil

    • I had a similar problem, it turned out that the double quotes in the above code block were not cutting and pasting well. (not sure why)

      I replaced the characters by hand and it worked fine, but it would probably be easier to grab Damien’s working page from:
      http://maketecheasier.com/maintenance.php

  6. Hm – sorry for all these questions, but maybe others have the same problems.
    Now, in the maintenance.php I’ve just replaced the mysite stuff and uploaded it to the site’s root.
    And – to the start of the .htaccess file I’ve added:
    Options +FollowSymlinks
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !/maintenance.php$
    RewriteCond %{REMOTE_HOST} !^62.16.191.158
    RewriteRule $ /maintenance.php [R=302,L]
    but the result to others (and me if I open dolcevita.no/maintenance.php) is
    Parse error: syntax error, unexpected T_LNUMBER in /home/2/d/dolcevita/www/maintenance.php on line 2
    (I also tried to enter the IP address as you had, like 62\.16\.191\.158 – but of course that won’t work.)
    Some obvious mistake?
    Thanks,
    Kjetil

  7. You were quite right! – so thanks a lot
    I’ve never been aware that there are two ways to write a quote mark:

    The curly ones from the bad pasting made the problem.
    Just one thing to add in: If your site lives in its own folder, eg /blogg should be added like this:
    Options +FollowSymlinks
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !blogg/maintenance.php$
    RewriteCond %{REMOTE_HOST} !^62.16.191.18
    RewriteRule $ /blogg/maintenance.php [R=302,L]
    …and with some styling work (eg using Dreamweaver) it even looks nice.
    Works like a charm!
    Kjetil
    PS Grabbing Damien’s page doesn’t work, but just reinsert all ” (quotes) and you’re on the right track

Comments are closed.

Sponsored Stories