Welcome to WebmasterWorld Guest from 54.166.199.178

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)

Full Member

10+ Year Member

joined:Aug 2, 2002
posts:216
votes: 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 ?

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

Senior Member

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

joined:Mar 31, 2002
posts:25430
votes: 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

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

Full Member

10+ Year Member

joined:Aug 2, 2002
posts:216
votes: 0


Thanks for the reply.

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

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

Senior Member

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

joined:Mar 31, 2002
posts:25430
votes: 0


Scooter24,

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

Jim

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members