Portal Home > Knowledgebase > Articles Database > Help with .htaccess allow deny


Help with .htaccess allow deny




Posted by denomolos, 05-17-2011, 11:33 PM
Hi. I'm using .htaccess to block IPs from a particular country, so it looks something like this: order allow,deny deny from 143.54.0.0/16 deny from 144.23.0.0/16 deny from 150.161.0.0/16 deny from 152.84.0.0/16 allow from all Now let's say I need to let in a single IP address from one of the blocked IP ranges, let's say 143.54.10.1 How would I go about doing that? I've tried putting "allow from 143.54.10.1" at the end but that doesn't work.

Posted by arunns, 05-18-2011, 01:00 AM
Can you try. order allow,deny allow from 143.54.10.1 deny from 143.54.0.0/16 deny from 144.23.0.0/16 deny from 150.161.0.0/16 deny from 152.84.0.0/16 allow from all ./arun

Posted by stardust_x7, 05-18-2011, 01:41 PM
Web servers can host many different domains on one hosting account under Linux/Apache, and public access to each domain and its folders and files can be controlled through the use of a .htaccess file to block a specific IP address, range of IP addresses, or multipleseparate IP addresses. The .htaccess file is typically found in the root folder of your domain (where you would also find the starting page for your web site) and is used for other purposes other than just controlling access to folders and files. Installing a .htaccess file is not limited to the web site root folder, however. You can install the .htaccess file in any of your sub-folders and the server will apply the rules only to site visitors that attempt to access a file in that folder or any sub-folders below Allow from All but Deny from a Specific IP Address(es) The format of the instructions to place into the .htaccess file for blocking access to a protected area is as follows: These instructions tell the web server to deny all requests to the web site protected area from IP addresses 99.999.999.991, 99.999.999.992, and 99.999.999.993, but allow requests from all other IP addresses. Deny from All but Allow from a Specific IP Address(es) You may also want to limit access to a folder only to a specific IP address or range of IP addresses. The format is the same but the contents of the .htaccess is slightly different. In this case you are denying access from everyone but allowing access to only specific IP addresses or domain names.

Posted by denomolos, 05-18-2011, 07:58 PM
thanks, but this doesn't work

Posted by Lux Newbie, 05-19-2011, 01:00 AM
I think you sould follow stardust_x7. Please check order allow then deny, or deny then allow



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read