Apache deny and allow access from ipaddress

With help of a .htaccess file we can deny or allow access from a specific ip address or range of ip addresses.

Deny access from all IP addresses in the range 192.168.2.*:

<Limit GET HEAD POST>
order allow,deny
allow from all
deny from 192.168.19.
</Limit>

The line order allow,deny means that Apache should first evaluate the allow entries (which states that everyone is allowed access) and then the deny entries (which states that the range 192.168.19.* is denied access). Effectively this means that the range 192.168.19.* is denied access.

Order of evaluation is allow, deny; so this means:
allow access from all
deny access from 192.168.19.

Allow only access from the IP range 192.168.19.*:

<Limit GET HEAD POST>
order deny,allow
allow from 192.168.19.
deny from all
</Limit>

Order of evaluation is deny, allow; so this means:
deny access from all
allow from 192.168.19.

Share

Leave a Reply

Your email address will not be published.