Knowledgebase: Web Hosting Related
.htaccess IP address block/allow rules may not work
Posted by Support, Last modified by Support on 29 April 2015 07:30 AM

If you are having trouble getting the Allow/Deny rules for IP address blocking/allowing in the .htaccess file, then your account may be on a server that has a web acceleration/caching system in front of it. To fix this issue change the rules to look like this:

If you have only 1 IP address to allow:

SetEnvIf X-Real-IP "111.222.333.444" allowclient
order deny,allow
deny from all
Allow from env=allowclient

 

If you have multiple IP addresses to allow:

SetEnvIf X-Real-IP "111.222.333.444|555.666.777.888" allowclient
order deny,allow
deny from all
Allow from env=allowclient

 

To block a single ip or multiple IPs:

SetEnvIf X-Real-IP "123.123.123.123" denyclient1
order allow,deny
allow from all
deny from 123.123.123.123
deny from denyclient1


If the above blocking lines done work, then try this:

SetEnvIf X-Real-IP ^(123\.123\.12\.|123\.123\.12\.123|123\.32\.22\.) denyclient1
Order Allow,Deny
Allow From All
Deny From env=denyclient1

(57 vote(s))
Helpful
Not helpful