Welcome to WebmasterWorld Guest from 54.205.75.60

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Blocking group of IP adresses with .htaccess

   
3:04 pm on Aug 8, 2002 (gmt 0)

10+ Year Member



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 ?

4:44 pm on Aug 8, 2002 (gmt 0)

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



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

5:39 pm on Aug 8, 2002 (gmt 0)

10+ Year Member



Thanks for the reply.

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

6:14 pm on Aug 8, 2002 (gmt 0)

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



Scooter24,

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

Jim