Forum Moderators: phranque
# REDIRECT EVERYONE TO SUBSCRIPTION FORM EXCEPT
RewriteCond %{REMOTE_ADDR} !^12\.34\.56\.78$ [OR]
RewriteCond %{REMOTE_ADDR} !^87\.65\.43\.21$
RewriteRule .* [domainname.com...]
I read the above as if visiter is NOT IP address 1 OR NOT IP address 2 refer to subscription page on another host.
When I use this code all visitors are refered to the subscription page, including the two IP addresses.
When I use 1 IP address like this
# REDIRECT EVERYONE TO SUBSCRIPTION FORM EXCEPT
RewriteCond %{REMOTE_ADDR} !^12\.34\.56\.78$
RewriteRule .* [domainname.com...]
this IP address goes to the index page of the website. When I remove the ! it will go to the sub page. This code works.
So, in my eyes the [OR] part of the code is not working.
Is there a way to make this code work? Where is my mistake?
Is there a better/another way doing this? If yes, an example please, because I am a beginner.
Thanks
Jim
Take the example Remote IP address 12.34.56.78
This matches the first rewritecond pattern, so that condition does not match (it is negated by "!")
But it does not match 87.65.43.21, so thre second RewriteCond does match, and the 302 redirect is taken.
Now reverse the test and try 87.65.43.21 first.
In fact an IP address cannot be NOT 1 OR NOT 2 at the same time, it will either match one negated condition or the other, or both.
Take the [OR] off your negative-match RewriteConds to get the default logical AND function. You want to redirect if the incoming address is NOT one and NOT the other.
"If it's NOT my IP address, AND it's NOT my mate's IP address, then send them off to somewhere else."
Jim