Welcome to WebmasterWorld Guest from 54.163.68.15

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)

10+ Year Member



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)

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



Something like:

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

Redirect if not me.

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

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



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)

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



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

10+ Year Member



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)

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



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