Posted on February 9, 2013 by
Spread the word...

Making large alterations to a website can cause disruption to the user and search engines, if not handled correctly. There are a few simple steps to follow which can help prevent any drastic drop-offs should a nasty surprise occur. This post covers how to handle setting up a maintenance page and setting a temporary header to postpone further indexing.

Even the a thoroughly thought out and planned migration can hit a bump which causes the entire site to return gibberish or just an error message. It’s never planned, but occasionally happens and helps to be prepared.

You may wish to implement a maintenance page for many reasons. Some of the most popular are:

  • Plugin incompatibility
  • Misconfiguration
  • Service outages
  • Missing files
  • Environment differences
  • The all-time favourite – human error!

301 maintenance page htaccess

The code below needs to be placed in the website’s main .htaccess file. If it already contains information, which is probably will, back it up until the site goes live again and switch it back.

RewriteEngine on
RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
RewriteRule .* /maintenance.html [R=302,L]

We can add an extra line of code to bypass the maintenance page for an I.P. address as below:

RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^123\.456\.789\.000
RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
RewriteRule .* /maintenance.html [R=302,L]

Simply replace “123\.456\.789\.000″ in the above code with your I.P. address and you can continue to work on the site while in maintenance mode.

The above code will redirect all visitors to the /maintenance.html page and tell search engines that the changes are temporary. It could just help prevent a massive drop in rankings by telling Google to ignore my incompetence… I mean, it’s a handy technique to know if everything goes pear-shaped during an update or while migrating databases.

Again, in an ideal world this would never be needed. But computers have a habit of doing what you say and not what you want. If I miss a full stop or comma, my website explodes and I worry more about my sysadmin than my mum!

Leave a Comment

Your email address will not be made public or shared. Inappropriate and irrelevant comments will be removed.