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:

Require all granted
Require not ip

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

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

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