Welcome to WebmasterWorld Guest from 23.20.206.245

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

.htaccess redirect

Redirect everyone but me...

     
8:34 pm on Aug 14, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Nov 23, 2003
posts:76
votes: 0


Hi,

I have a .htaccess question.

I currently have 2 sites exactly the same name but one has hyphons in the URL and one doesn't and I'm going to move one to the other.

The pages will be exactly the same on both sites.

While I develop the new one, I need to redirect anyone who goes to the NEW site back to the old one - expect me. I know this sounds the wrong way around, but I have links pointing to the new site, which are currently redirected to my old one.

I have this in my NEW site htaccess:

Options +FollowSymLinks
RewriteEngine On
RewriteRule (.*) [my-old-site.co.uk...] [R=301,L]

This works great - any page someone goes to on my new site, gets sent to the existing page equivalent on the old site.

Question is - what do I need to add to this to allow MY IP to remain on the new site while I work on it?

Thanks.

8:51 pm on Aug 14, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
posts:18903
votes: 0


Something like:

RewriteCond %{REMOTE_IP} !^12\.34\.56\.78

Redirect if not me.

9:20 pm on Aug 14, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


The variable should be %{REMOTE_ADDR}, as in:

RewriteCond %{REMOTE_ADDR} !^12\.34\.56\.78$

Jim
9:27 pm on Aug 14, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
posts:18903
votes: 0


Ooops. Apologies. I knew it wasn't REMOTE_HOST but still messed up.
10:33 pm on Aug 14, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Nov 23, 2003
posts:76
votes: 0


Thanks for the answers,

I am not good at all when it comes to .htaccess - is this all I need to put in the .htaccess file? or does it need to go with other lines?

If that is all I need, can I put it anywhere?

Thanks again!

Dramstore.

10:41 pm on Aug 14, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


Add the RewriteCond to your existing RewriteRule. Please read the mod_rewrite documentation [httpd.apache.org] at apache.org (and the URL Rewriting Guide linked from that document) if you intend to use mod_rewrite -- It is a compact, powerful, and possibly-dangerous module -- You can easily take your server off-line or ruin your search engine rankings with a single typo or an unforeseen side-effect.

Our goal here is to help you learn how to write your code, but not to write it for you, so please look at the docs.

Jim