SEO & Social Media Canterbury Kent – Amby Marketing

How To Redirect Website Traffic To A Maintenance Page


Sometimes, you will want to perform some work on your website, but at the same time, let visitors know that the site is being worked on and not broken.

One easy solution is to modify the .htaccess file and temporarily redirect your visitors to a maintenance page which can display a nice simple message updating them of your progress.

The code below allows you to do just that and also allows you to exclude your own ip address so that you can modify your site and avoid being restricted like everyone else.

Note: This is for apache based web servers only. You will need to search for another solution if you are running Windows IIS or other web server software.

You need to post the following code to the top of your .htaccess file.

<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteBase /
 RewriteCond %{REMOTE_ADDR} !^78\.148\.179\.119$
 RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]
 RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
 RewriteRule ^.*$ /maintenance.html [R=302,L]

On line 5, you can see an IP address. You need to change this to your own real world IP address so that you can see the site and not the maintenance page. So go to Google and search for “show my ip address” and Google will usually let you know your ip.

Alternatively, you can go to one of many sites that automatically show your IP. Try

The code on line 6 is there to make sure you don’t get a redirect loop.

Line 8 redirects the users to the maintenance.html page which in this case is located in the root directory of the site.

A bog standard html page with something like the following will do nicely. Or you can style it or put it in one of your sites templates.

<title>Maintenance Page</title>
<h2>Maintenance Page</h2>
<p>Sorry, but the site is currently undergoing a face-lift!</p>
<p>Please return in around 1 hour to see our new site.</p>

When you have finished updating your site, don't forget to remove the code that you previously placed at the top of the .htaccess file.

Good luck!

You can follow any responses to this entry through the RSS feed. Both comments and pings are currently closed.

Tagged , ,

Comments are closed.