| Welcome to WebmasterWorld Guest from 126.96.36.199 |
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:
188.8.131.52 - 184.108.40.206
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