htaccess restrict sub dir to my IP not working

Order deny,allow
deny from all
allow from xx.xx.x.xx  
RewriteRule . - [F]

I have the above in a .hta file in a subdir of my site where I am trying to restrict access to that directory and its subs to ONLY my IP. I have a static IP and I have checked the IP entered is correct, yet it will not allow my IP ...

What am I doing wrong here ?

Answers


You need to remove the RewriteRule. RewriteRule . - [F] will not differentiate between IPs and the rule will always be applied, so regardless of whatever the request is (except for /), you will always be forbidden ([F]).


Update:

If it's a parent's directive, try adding AllowOverride Limit to the top of the file (and still removing the RewriteRule)

If there's still something that prevents you from overriding parent directory rules, you can do it purely by the RewriteEngine:

RewriteCond %{REMOTE_ADDR} !^xx.xx.x.xx$
RewriteRule . - [F]

This will add the condition to the forbidden rule that the remote address (the client connecting) isn't xx.xx.x.xx, if it is, the condition fails and the rule won't be applied.


Need Your Help

Yii2 - GridView - How to enclose the table data within html tags?

gridview yii2 yii2-advanced-app

I am new to yii2. I am trying to enclose the table data of GridView within anchor tag.

How access value of the system value using Digital Metaphors ReportBuilder RAP

delphi reportbuilder

I'm using Digital Metaphors ReportBuilder in Delphi 2007. I'd like to access the system date (the value of the now function in Delphi) using RAP, but get an undeclared identifier error when attemp...