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 )
EDIT: I'v also tried:
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^my_ip$ [OR]
RewriteCond %{REMOTE_ADDR} !^server_ip$
RewriteCond %{HTTP_HOST} ^.*site1 [NC]
RewriteRule ^(.*)$ http://site2/$1 [R=301,L]
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !=my_ip [OR]
RewriteCond %{REMOTE_ADDR} !=server_ip
RewriteCond %{HTTP_HOST} ^.*site1 [NC]
RewriteRule ^(.*)$ http://site2/$1 [R=301,L]
RewriteEngine on
RewriteCond %{REMOTE_ADDR} ^my_ip$ [OR]
RewriteCond %{REMOTE_ADDR} ^server_ip$
RewriteRule ^(.*)$ http://site1/$1 [L]
RewriteCond %{HTTP_HOST} ^.*site1 [NC]
RewriteRule ^(.*)$ http://site2/$1 [R=301,L]