How to exclude IP from htaccess domain redirect

Posted by ijujym on Server Fault See other posts from Server Fault or by ijujym
Published on 2012-08-30T12:52:53Z Indexed on 2012/08/30 15:40 UTC
Read the original article Hit count: 208

Filed under:

I'm trying to write a custom redirect rule for some testing purposes on 2 domains with exactly same site. The code I am using is:

  RewriteEngine on
  RewriteCond %{REMOTE_ADDR} !^1\.2\.3\.4$
  RewriteCond %{HTTP_HOST} ^.*site1.com [NC]
  RewriteRule ^(.*)$ http://www.site2.com/$1 [R=301,L]

What I want is to redirect all requests for site1 to site2 except for requests from IP address 1.2.3.4. But currently requests from that IP are also being redirected to site2.

Is there something I've missed in settings?

( note: both domains are on the same shared hosting account )

© Server Fault or respective owner

Related posts about .htaccess