working - redirect ip address htaccess
Blocking IP range in htaccess file (4)
I'm managing a site and the site is built in Wordpress. It gets ENORMOUS amount of traffic from bots and we want to block all of them except for important bots like Google Yahoo Bing Baidu. We use cloudflare and I want to block them from two layers, Cloudflare firewall and htaccess file. In htaccess file, I know how to block a single IP address and last trailing IPs of a IP range like 188.8.131.52/16
However, I need to block following IPs 184.108.40.206 - 220.127.116.11 18.104.22.168 - 22.214.171.124
How do you set rules of this in htaccess file? Cloudflare seems to follow same rule.
I’ve just used
Order Allow,Deny Deny from 188.143.*.* Allow from all
as spam attack comes from
Not sure how reliable the source is, but this is from clockwatchers
To Block a single ip address
order allow,deny deny from 127.0.0.1 allow from all
This will refuse all GET and POST requests made by IP address 127.0.0.1, an error message is shown instead
To block multiple ip addresses, list them one per line
order allow,deny deny from 127.0.0.1 deny from 127.0.0.2 deny from 127.0.0.3 allow from all
To block an entire ip range
deny from 127.0.0
This will refuse access for any user with an address in the 127.0.0.0 to 127.0.0.255 range.
Edit: Just found a similar question here
Looks like out answers are similar too.
Use just the first 3 octets
Order Allow,Deny Deny from 66.249.74. Allow from all
You've almost got it. The /16 notation is actually called CIDR Notation.
The number indicates how many bits to match from left to right. The Wiki page explains it in depth.
Or... you can just take my word for it and use a tool like this one I found: http://www.ipaddressguide.com/cidr#range
You can then use the deny from in your .htaccess just as you would for a single ip with the given values:
Order Allow,Deny Deny from 126.96.36.199/18 Deny from 188.8.131.52/29 Allow from all