1

Hello ~ this is my first post to stackoverflow

We are trying to satisfy the following criteria in our htaccess file:

If you are not in a certain range of IP addresses (111.222.xxx.xxx) and the http host is test.com, then take the user to test.com/goodbye:

RewriteCond %{REMOTE_ADDR} !^111\.222
RewriteCond %{HTTP_HOST} ^test\.com$
RewriteRule ^.*$ http://test.com/goodbye [R=301,L]

If you are in a certain range of IP addresses (111.222.xxx.xxx) and the https host is test.com then take the user to test.com/hello:

RewriteCond %{REMOTE_ADDR} ^111\.222
RewriteCond %{HTTP_HOST} ^test\.com$
RewriteRule ^.*$ http://test.com/hello [R=301,L]

no matter which IP I use, I am taken to /hello. I assume the first condition is failing somehow?

1 Answers1

1

Reverse the rules and make your regex more strict:

RewriteCond %{REMOTE_ADDR} ^111\.222\.
RewriteCond %{HTTP_HOST} ^test\.com$
RewriteRule !^hello /hello [R=301,L]

RewriteCond %{REMOTE_ADDR} !^111\.222
RewriteCond %{HTTP_HOST} ^test\.com$
RewriteRule !^goodbye /goodbye [R=301,L]
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • thanks for your comment anubhava ~ I believe my issue may be related to browser caching. We are trying to show people a message if they are in a certain IP range, to sign into a VPN. Once signed in, another page should load. – user1967926 Feb 12 '14 at 20:13