tags:

views:

23

answers:

2

i want to get access to a ip range with this net feature: 68.241.45.0/20 in .htaccess file and in RewriteCond. some thing like this:

RewriteCond %{REMOTE_HOST} !^68.241.45.0/20

but it seem doesn't work.

would you help me?

+1  A: 

RewriteCond uses regular expression on the second parameter. So you need to escape the dots (.) and use regex for the range.

^68\.241\.[32|47]\.[1|2]?[0-9]+?

Ruel
+1  A: 

With RewriteCond you can only do regular expression or lexicographic comparison. And since 68.241.45.0/20 is the range from 68.241.32.1–68.241.47.254, you could do this:

# regular expression comparison
RewriteCond %{REMOTE_HOST} ^68\.241\.(3[2-9]|4[0-7])\.\d+$

# lexicographic comparison
RewriteCond %{REMOTE_HOST} ^68\.241\.(\d+)\.\d+$
RewriteCond %1 >31
RewriteCond %1 <48
Gumbo
thanks Gumbo !!!
hd