How to display a maintenance page whilst upgrading WordPress
Posted 16 May 2007, by Aaron

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:

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!

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:

Paul Enderson
17 May 2007, 1:11 am