Block Range of IP while excluding others
4 posts
• Page 1 of 1
Block Range of IP while excluding others
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
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
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Block Range of IP while excluding others
Hello,
You can try using the following:
Regards
Andrew
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
Re: Block Range of IP while excluding others
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
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
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Block Range of IP while excluding others
Yes, why not.
Regards
Andrew
Regards
Andrew
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 13 guests