Possible Duplicate:
301 redirects for all except me

I've been developing a new version of my website for a while now, on a different directory to my currently-live website.

Shortly I'll be ready to move this directory to root and do a mass search and replace on the database dump.

However, for the short period whilst I take the old files offline and put the new site in place - and test it to make sure everything is working correctly - I'd like to put up a "coming soon, version 2 of the website!" image to all users apart from myself.

When I access the website, I want to be able to see everything as usual so that I can work on it.

What's the best way to go about this?

Thanks in advance,


3 Answers 3


Based on this example you could use php to show one page to your ip address and another to everyone else.

PHP - this sends a 302 by default

$visitor = $_SERVER['REMOTE_ADDR'];
if (preg_match("/",$visitor)) {
      header('Location: http://www.yoursite.com/thank-you.html');
} else {
      header('Location: http://www.yoursite.com/home-page.html');

Htaccess 1

You can also achieve the same thing with htaccess, customising the 403 error page as you like.

order Deny,Allow
Deny from all
Allow from my.ip.add.ress

ErrorDocument 403 /forbidden.html

Htaccess 2 Rewrite Rule with 503 code

RewriteEngine on
RewriteCond %{ENV:REDIRECT_STATUS} !=503
RewriteCond %{REMOTE_HOST} ^192\.168\.0\.1
ErrorDocument 503 /redirect-folder/index.html
RewriteRule !^s/redirect-folder$ /redirect-folder [L,R=503]

Status 301, 302 or 503

Also remember with this and other types of redirect that you should use a 302 redirect for temporary re-directions rather than a 301 which signals to Google it's a permanent re-direction you can also use a 503 'temporarily down' code to signal to search engines that they shouldn't index your holding page.

Check the list of status codes to choose the most appropriate.


Think I've found a link on here which I should've noticed in the first place:

301 redirects for all except me

I suspect this will do the trick for me perfectly.

  • That looks like it should work, if you're happy with the answer, please accept it by clicking the tick. Commented Feb 20, 2012 at 12:42
  • 2
    Also remember that you should use a 302 redirect en.wikipedia.org/wiki/HTTP_302 for temporary re-directions rather than a 302 which signals to Google it's a permanent re-direction. Commented Feb 20, 2012 at 12:43
  • Two days until I can accept my own answer, otherwise I would have. Thanks for your answer, apologies I didn't notice in time before I wasted your time.
    – turbonerd
    Commented Feb 20, 2012 at 12:44
  • 1
    @toomanyairmiles typo... "rather than a 302", that should be 301. :)
    – MrWhite
    Commented Feb 20, 2012 at 14:23

Why not develop on a local server and when ready commit it to your live site? Are you making significant database changes or are you only doing search and replace to update the path from your sub folder development area to the root folder? Using redirects and coming soon pages might affect your rankings in Google. If you can avoid it you should and find another way to update without having to redirect everyone with a coming soon page.

  • The site should be down for less than 10 minutes if everything goes to plan. However, we currently we have around 35,000 unique visitors per week so I would expect a reasonable amount of traffic for those 10 minutes - I don't want users to think the site is broken. Also, potentially, it could take longer. I'm moving a WordPress installation to the root directory which should simply be a case of changing the URLs in the database (export, find&replace, import) but I'll also need to run a thumbnail generator - that could take a lot longer on the 4,000 images we have.
    – turbonerd
    Commented Feb 20, 2012 at 14:37
  • The options table stores the url of your site, plugins may have also set the sites url. There is a plugin for wordpress to find and replace, I would search through the database manually at first making a note of every place the sub folder is listed before running the update. Posts that contain images, widgets etc anything you inserted into posts or pages could be using the sub folder but definitely check manually first all tables that contain the sub folder URL before making the update. I've ran into some trouble with find and replace scripts before.
    – Anagio
    Commented Feb 20, 2012 at 15:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.