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