How to Block an IP address range using the .htaccess file
Solution 1
You could use:
Order Allow,Deny
Deny from 66.249.74.0/24
Allow from all
Or you could use this:
RewriteEngine on
RewriteCond %{REMOTE_ADDR} ^66\.249\.74\.
RewriteRule ^ - [F]
Solution 2
Use just the first 3 octets
Order Allow,Deny
Deny from 66.249.74.
Allow from all
Solution 3
I’ve just used
Order Allow,Deny
Deny from 188.143.*.*
Allow from all
as spam attack comes from xxx.xxx.0-80.0-80
.
Solution 4
You can go to: and enter ips and it will generate the file for you. http://www.htaccesstools.com/block-ips/
Also for example you want to block the ip address range
you want would be:
Order Allow,Deny
Deny from 66.249.74.0/24
Allow from all
Or You Can Do:
You can indicate which addresses you wish to block using RewriteCond %{HTTP_REFERER}
.
This is a Working Example:
# BLOCK VISITORS REFERRED FROM GOOGLE.COM
RewriteCond %{HTTP_REFERER} ^https?://([a-z0-9-]+\.)?google\.com [NC]
RewriteRule .* - [F]
The example above uses a regular expression, so it will block:
-
https://
orhttp://
- followed by any subdomain (or none)
- followed by
google.com
- followed by anything (or nothing)
The [F]
flag means Forbidden
. The server will return a 403 Forbidden Error
.
Msy Marina
Updated on August 03, 2020Comments
-
Msy Marina over 3 years
I have detected that a range of IP addresses may be used in a malicious way and I don't know how to block it.
I would like to block the range 66.249.74.* from accessing my website by using the .htaccess file.
-
Msy Marina over 10 yearsI want to tell you that , I use Common100 Online chat software for detect who visiting on my website page , and i always found this IP address visit 66.249.74.* . Please see the image ! laroute-angkor.com/IP.jpg So what should i do ?
-
Prix over 10 years@MsyMarina that IP is from google whois.arin.net/rest/net/NET-66-249-64-0-1/pft
-
Msy Marina over 10 yearsSorry, I don't know whois.arin.net/rest/net/NET-66-249-64-0-1/pft But i don't want see those IP access on my website .
-
Prix over 10 years@MsyMarina does Google send you virus?
-
Msy Marina over 10 yearsI haven't receive any virus from google , but i want to make sure that this IP address is from google navigating on my webpage is normal like another website ,right ?
-
Prix over 10 years@MsyMarina that site I have sent above is a trusted site that tracks the owners of each IP block, it says those IP's are from google so yes you have nothing to fear.
-
Msy Marina over 10 yearsI need that point , thank for your value time for help me clear .
-
Reverse Engineered over 6 yearsCan you please explain what the /24 does? Why the number 24?
-
Prix over 6 years
-
Ralf about 6 yearsIf anyone, like me, is wondering where the /24 comes from: google "netmask" or "subnet mask". Basically it means "24 first bits" matter, 24 = 3 x 8 bits. See dslreports.com/faq/8426