| Welcome to WebmasterWorld Guest from 220.127.116.11 |
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
|Become a Pro Member|
|Blocking group of IP adresses with .htaccess|
I'd like to block this group of IP addresses:
18.104.22.168 - 22.214.171.124
I might do it with 64 "deny from" lines:
allow from all
deny from 213.1.64
deny from 213.1.65
deny from 213.1.127
Is there a more concise way of doing this ?
Using regular expressions, something like this would do it.
deny from ~ "213\.1\.(6[4-9]¦[7-9][0-9]¦1[0-1][0-9]¦12[0-7])"
I just whipped this out, and I encourage you to check it thoroughly before use. One typo, and the
whole thing blows up. Here is a handy regex reference [etext.lib.virginia.edu].
Thanks for the reply.
Why do you need the "~" character after the deny from ?
The "~" enables parsing of regular expressions in this context.
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved