This tutorial describes How To Block IP using .htaccess in Apache. The Apache users can easily block website access from specific IP addresses or any IP ranges using the .htaccess file. Make sure your Apache server is enabled to use a .htaccess file.
Block IP using .htaccess
Now, create a file named .htaccess in your website document root directory and add these example lines:
Advertisement
1 2 3 4 5 6 7 8 | <Files *> <RequireAll> Require all granted #First allow all Require not ip 192.168.1.10 #Block single IP Require not ip 192.168.1.0/24 #Block IP range Require not ip 192.168.1.11 10.10.0.1/32 #Block mutile IPs and range </RequireAll> </Files> |
You are required to change the IP address to be blocked in the above configuration. Here you can block a single IP or IP ranges. You can also write one or more IPs in a single line with space separated.
The user will see the following error message when tried to access from a blocked IP address.
For more details visit the following link:
https://httpd.apache.org/docs/2.4/howto/access.html
1 Comment
Hey Rahul,
I just blocked an ip which sends me 1423 requests every 15 minutes. The ip is showing as Googlebot. But it affects my loading speed. Sometimes my site is unable to access just for the only ip.
So, I tried to block that ip. But after blocking the ip I got the forbidden message on my site. Can you please tell me what can I do?
Best Regards,
Amrit