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:
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…