Prevent or allow domain access for a specified range of IP addresses - There are several effective ways to block a range of IP addresses via htaccess. This first method blocks an IP range specified by their CIDR (Classless Inter-Domain Routing) number. This method is useful for blocking mega-spammers such as RIPE, Optinet, and others.
# block IP range by CIDR number <Limit GET POST PUT> order allow,deny allow from all deny from 10.1.0.0/16 deny from 80.0.0/8 </Limit> Likewise, to allow an IP range by CIDR number: # allow IP range by CIDR number <Limit GET POST PUT> order deny,allow deny from all allow from 10.1.0.0/16 allow from 80.0.0/8 </Limit> Another effective way to block an entire range of IP addresses involves truncating digits until the desired range is represented. As an IP address is read from left to right, its value represents an increasingly specific address. For example, a fictitious IP address of 99.88.77.66 would designate some uniquely specific IP address. Now, if we remove the last two digits (66) from the address, it would represent any address beginning with the remaining digits. That is, 99.88.77 represents 99.88.77.1, 99.88.77.2, 99.88.77.99, etc. Likewise, if we then remove another pair of digits from the address, its range suddenly widens to represent every IP address 99.88.x.y, where x and y represent any valid set of IP address values (i.e., you would block 256*256 = 65,536 unique IP addresses). Following this logic, it is possible to block an entire range of IP addresses to varying degrees of specificity. Here are few generalized lines exemplifying proper htaccess syntax (edit values to suit your needs): # block IP range by address truncation <Limit GET POST PUT> order allow,deny allow from all deny from 99.88.77.66 deny from 99.88.77.* deny from 99.88.*.* deny from 99.*.*.* </Limit> Likewise, to allow an IP range by address truncation: # allow IP range by address truncation <Limit GET POST PUT> order deny,allow deny from all allow from 99.88.77.66 allow from 99.88.77.* allow from 99.88.*.* allow from 99.*.*.* </Limit>