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.

Advertisement

Block IP using .htaccess

Now, create a file named .htaccess in your website document root directory and add these example lines:

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.

Block IP using .htaccess

For more details visit the following link:

https://httpd.apache.org/docs/2.4/howto/access.html

Share.

1 Comment

  1. 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

Leave A Reply

Exit mobile version