Sometimes it becomes necessary to block access to the site or part of it from certain IP addresses.

In this case, you need to create a .htaccess file with directives in the desired directory. For example, to deny access from IP address 172.16.16.16:

Order Allow,Deny
Allow from All
Deny from 172.16.16.16

Now, when trying to access the site from the IP address 172.16.16.16, the visitor will receive a 403 error or your page for this error.

Specifying part of the address in the form 172.16.16 will restrict access from the 172.16.16/24 subnet.

Was this answer helpful? 29 Users Found This Useful (91 Votes)