homepage Welcome to WebmasterWorld Guest from 54.145.238.55
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Blocking group of IP adresses with .htaccess
Scooter24

10+ Year Member



 
Msg#: 10 posted 3:04 pm on Aug 8, 2002 (gmt 0)

I'd like to block this group of IP addresses:
213.1.64.0 - 213.1.127.255

I might do it with 64 "deny from" lines:
order allow,deny
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 ?

 

jdMorgan

WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 10 posted 4:44 pm on Aug 8, 2002 (gmt 0)

Scooter24,

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].

Jim

Scooter24

10+ Year Member



 
Msg#: 10 posted 5:39 pm on Aug 8, 2002 (gmt 0)

Thanks for the reply.

Why do you need the "~" character after the deny from ?

jdMorgan

WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 10 posted 6:14 pm on Aug 8, 2002 (gmt 0)

Scooter24,

The "~" enables parsing of regular expressions in this context.

Jim

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved