Blocking of IP in .htaccess not working Blocking of IP in .htaccess not working apache apache

Blocking of IP in .htaccess not working


Probably a red herring, but I presume you have the tags around your .htaccess block? eg

<Limit GET POST>  order allow,deny  allow from all  deny from 100.101.102.103</Limit>

This is how I use it on one of my sites.


Are you sure that the ip address you are including is the ip address that Apache is seeing? If the server is behind a load balancer, it will see the load balancer address.

To overcome this, you need to examine the X-Forwarded-For header

        SetEnvIf X-Forwarded-For ^aaa\.bbb\.ccc\.ddd proxy_env        Order allow,deny        Satisfy Any        deny from env=proxy_env

You can obviously check what ip address is being seen by looking at your logs


I came accross a similar issue recently, this was all about IPv4 and IPv6. Have a look at your server's access logs, and check how your IP address is logged. You might actually be blocking an IPv4 address, while reaching your web server with your IPv6 address (which is not blocked).

If you don't have access to these logs, just try to block your IPv6 the same way you're trying to block your IPv4. You can find your IPv6 here : http://whatismyv6.com/

Order Allow, DenyAllow From AllDeny From [Your-IPv4]Deny From [Your-IPv6]