Main Website RSS FeedCurrent Article

Using Temporary Maintenance Page when Upgrading Wordpress

This is the very first time i need to use a temporary server maintenance page, previously when i upgrade wordpress (even to major release such as this one) … there’s no need for me to redirect this site visitors to a temporary page saying that this server is under maintenance, but this time the situation is different

And that’s because i do not want my visitors to see lots of beautiful MySQL error message when viewing every page of this site (i’m quite sure you feel the same way too) because of the recent database schema changes in Wordpress 2.3, but … how to do that ? if you ask me …

The answer is simple, as long as you have access to edit your .htaccess file (some web hosting company doesn’t allow you to edit the .htaccess file, and that’s why i said so) :)

And here are the complete instruction :

1. Create a new html page saying that this site under maintenance or anything you like :) , and save it as maintenance.html (this is just an example, feel free to use another filename)

2. Edit your .htaccess file in your root public_html directory

and add these lines :

RewriteCond %{REMOTE_ADDR} !^123\.456\.789\.0
RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]
RewriteRule .* /maintenance.html [R,L]

Note : Replace 123\.456\.789\.0 with your own ip address

And here are the description about what the above line does :

  1. The first RewriteCond is used so that you can still access your site, by detecting your ip address
  2. The second RewriteCond is used so that every request to maintenance.html file will not be redirected, this is used to prevent infinite redirect loop
  3. The third RewriteCond is used so that others that is trying to access your site in any page will be redirected automatically to your maintenance.html page using temporary redirect so that search engine robot will check again later

3. Now you just need to upload the above file into your public_html directory and continue the upgrade process

But what if you’ve finished upgrading your wordpress, and you want your visitors will able to view your site again ?

Simple … you just need to remove the above .htaccess rules, and to make sure that your site visitors will be automatically redirected to your main page, you can add below line to your .htaccess file

Redirect 301 /maintenance.html http://www.yourdomain.com

And you’re done :)

RSS Feed for This Post2 Comment(s)

  1. 1
    retro | Nov 1, 2007 at 21:43 / 9:43 PM | Links to this comments | Reply

    I do love the classics.

  2. 2
    Jeremy | Aug 1, 2008 at 8:41 / 8:41 AM | Links to this comments | Reply

    Perfect - thank you. I had to figure this out in the absence of my developer today...and you spelled it out nicely, even for non-tech-types like myself. Thanks again.

RSS Feed for This PostPost a Comment

Line and paragraph breaks automatic, e-mail address never displayed, avoid using spammy words or phrases to prevent your comment from going into the oblivion, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>