Articles

How to Block IP Addresses with .htaccess

If you suspect you are under attack from a specific IP address, you can block it from accessing your server by using a service like CloudFlare or by using security plugins if you're running WordPress.

However, if you wish to manually block an IP address, you can do so by adding the following to your app's .htaccess file:

<RequireAll>
Require all granted
Require not ip 1.2.3.4
</RequireAll>

Be sure to replace 1.2.3.4 with the IP address to be blocked.

You may block multiple IPs by repeating the line Require not ip 1.2.3.4 for each address you wish to block.

Apache also offers more information on configuring access control from your app's .htaccess file.