How to display a maintenance page whilst upgrading WordPress

Minimum maintenance road

It’s that time again where WordPress users across the globe shut down all their systems, cross every finger they’ve got, and do the dreaded upgrade.

It’s a horrible process that involves disabling all plugins, backing things up and uploading the new files. Then you gradually switch things back on, realise that something is not working, curse terribly and fiddle with the code, before eventually - after a good period of downtime - you get things back to normality.

WordPress 2.2 has made things even more complicated as many of the file names have been changed. This means that you need to completely delete the old installation from your server.

Meanwhile, any unsuspecting visitors to your site during this downtime get a mixture of server errors, page not found messages, or a site that just looks completely broken.

However, it is really easy to redirect all your visitors to a simple maintenance page using a .htaccess redirect. And I shall explain how.

1. Create a maintenance.html file

Create a very simple HTML file. And I do mean simple. This technique does not allow you to use the < IMG > tag so just write a couple of text lines explaining that the site is undergoing maintenance and to check back in 30 minutes, then save the file as maintenance.html.

Mine looks like this:

Maintenance page screenshot

See, I told you this was easy.

2. Create the .htaccess redirect

Open up your favourite text editor, paste in the following text and save the file as .htaccess

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !/maintenance.html$

RewriteRule $ /maintenance.html [R=302,L]

3. Do the WordPress upgrade

You will need to upload the two files you have created but it is REALLY IMPORTANT that FIRST you backup your old .htaccess file and switch off all your plugins. Then you can upload maintenance.html and your new .htaccess file to your root folder, and now all visitors across your entire site will be redirected to the temporary maintenance page.

Once you have completed the rest of the upgrade process, simply replace the .htaccess file with the backup you made earlier. Now you should be able to log back in to WordPress, reactive all your plugins, and all things going well, you should be running a new and improved version of WordPress. Nice!

WordPress 2.2 installed

This little how-to comes with the usual disclaimer that if your site completely breaks, then it had nothing to do with me, guv. However, if you do have any questions then I’m happy to have a bash at answering them.

Many thanks for all the recent comments: David, Paul, Sera, Tara, Scot and Johno.

Related articles:

Tags:, ,

5 fantastic comments

That’s a nice way of doing things… When (if) I get the chance to do my upgrade later then I may just use that! ;)

Great idea! I’m about to upgrade to 2.2 (I always dread these upgrades). I’ll be using your suggestion.
Have you noticed any improvements with 2.2?

Thanks for the comments guys. It’s an easy step to take and ensures things look a little neater for any visitors during your upgrade.

Johno - To be honest… no I haven’t really. 2.2 claims to be more streamlined and faster, but I cant say I had any problems before with speed. The main change is the introduction of native widget support. I’ve never used widgets with wordpress so I’ll have to have a play around and see what they’re all about.

Have just upgraded to 2.2.1 and used your method. Worked great, so thanks again.

Glad it worked for you Johno. :)

Have your say

By commenting you are agreeing to the miLienzo.com comment policy.