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.
Give us your feedback on this article
Did this help you?
Want to speed up your site, easily?
Set up your site on Servebolt, free of charge for 60 days, and see for yourself how fast it can be on our extremely fast hosting.
A faster site converts better, ranks better on Google, and is better for the climate.