Block Range of IP while excluding others

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 18
Joined: 06 Apr 2012, 23:12

Block Range of IP while excluding others

16 Apr 2012, 15:39

Hello, I now have the following code in my htaccess file to block ip address ranges:

RewriteCond %{REMOTE_ADDR} ^(?:84\..*\..*\..*|83\.211\..*\..*|85\.12\.25\..*|83\.233\..*\..*)
RewriteRule (.*) $1 [F]

If I needed to make exclusions is there an easy way. For example, say I need to block all the ranges that start with 84

84\..*\..*\..*

except
84\.211\..*\..*
84\.15\..*\..*
84\.120\..\..*

Thanks!
Shawn

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Block Range of IP while excluding others

18 Apr 2012, 06:13

Hello,

You can try using the following:

Code: Select all
RewriteCond %{REMOTE_ADDR} ^(?:84\..*\..*\..*|83\.211\..*\..*|85\.12\.25\..*|83\.233\..*\..*)
RewriteCond %{REMOTE_ADDR} !^84\.(?:211|15|120)\..*\..*
RewriteRule (.*) $1 [F]


Regards
Andrew

User avatar
Posts: 18
Joined: 06 Apr 2012, 23:12

Re: Block Range of IP while excluding others

20 Apr 2012, 00:01

Thank you! So will this method also work?

RewriteCond %{REMOTE_ADDR} ^(?:84\..*\..*\..*|83\.211\..*\..*|85\.12\.25\..*|83\.233\..*\..*)
RewriteCond %{REMOTE_ADDR} !^(?:84\.211\..*\..*|84\.15\..*\..*|84\.120\..*\..*|83\.233\..*\..*|83\.119\..*\..*|83\.114\.24\..*|85\.121\..*\..*|85\.10\.15\..*)
RewriteRule (.*) $1 [F]

Thank you,
Shawn

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Block Range of IP while excluding others

20 Apr 2012, 06:39

Yes, why not.

Regards
Andrew

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 13 guests