Mod_Rewrite: filter specific pages by IP and redirect them

I am looking into a way to work with filtering certain pages by IP and redirecting them to another page.

The code below doesn't work as expected.

RewriteCond %{REMOTE_ADDR} ^/192.168.10.*
RewriteCond %{REQUEST_URI} ^/support
RewriteRule ^/.* http://www.yahoo.com/gone [R,NE]

      

Once the link http://example.com/support was available and they are in block 192.168.10. *, it should go to the yahoo.com Sample Page.

But as I said. He just didn't do anything. Any ideas why this didn't work correctly?

+2


source to share


1 answer


as yoda says in the comment, don't put /

before the ip address. Also, it .

should be in the pattern \.

, as it is a perl compatible regex. you can also add [NC]

, no case (sensitive) to query uri match. finally, you can combine the second condition with RewriteRule

. together:



RewriteCond %{REMOTE_ADDR} ^192\.168\.10\..*
RewriteRule ^/support http://www.yahoo.com/gone [R,NE,NC]

      

+4


source







All Articles