views:

223

answers:

1

Hi All,

I am researching a way to work filtering specific pages by IP and redirect them on a different page.

The code below, did not work properly.

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 has been accessed and they're on the 192.168.10.* block, it must go to the yahoo.com example page.

But, like I said. It just did nothing. Any ideas why it did not work correctly?

+1  A: 

as yoda says in the comment, don't put a / in front of the ip address. also, the . in the pattern should be \., as this is a perl compatible regular expression. you could also add a [NC], no case (sensitive), to the request uri match. finally, you could merge the second condition with the RewriteRule. all together:

RewriteCond %{REMOTE_ADDR} ^192\.168\.10\..*
RewriteRule ^/support http://www.yahoo.com/gone [R,NE,NC]
ax
Thank you! If I want a specific IP, would this do?RewriteCond %{REMOTE_ADDR} ^192\.168\.10\.148*Shall I retain the asterisk (*)?
Louie Miranda
no asterix at the end - this would also match 192.168.10.14 (asterix means zero or more matches of the preceding '8'). better do ^192\.168\.10\.148$ (the $ meaning anchoring to the end of line).
ax