Restricting access based on IPs
If you want to deny access to a certain IP address using
.htaccess, you can add the following to the top of your
.htaccess file that is located in the public folder of your site:
<RequireAll> Require all granted Require not ip IPADDRESSTOBLOCK </RequireAll>
Similarly, you can also lock all access to a certain IP, for example if you only want to be able to access the website yourself:
<RequireAll> Require all granted Require ip IPADDRESSTOALLOW </RequireAll>
If you want to block or require multiple IPs, you can just add more lines with Require IP/Require not IP with the ipv4, ipv6 or subnets CIDR format.