Reputation: 1747
I tried the following but DOESNT work(no body can access the file including the IP that i want it to access)
<Files something.php>
Order allow,deny
Deny from all
allow from zzz.zzz.zzz.zzz
</Files>
I want to deny the access to a file to all the world except one ip, how do i do this? Thanks
Upvotes: 3
Views: 5101
Reputation: 171
The reason it did not work is because your Deny
directive overrode your Allow
directive.
What Order Allow,Deny
does is:
Allow
, flag "allow" if any matched.Deny
, flag "deny" if any matched (even if previously matched by Allow
)So, it is required that you remove Deny from All
if you do not want all requests to be Denied. Just a note for MickeyRoush's answer.
As for Order Deny,Allow
, it's the "opposite":
Deny
, flag "deny" if any matched.Allow
, flag "allow" if any matched (even if previously matched by Deny
)See the link MickeyRoush gave for more information.
Upvotes: 1
Reputation: 1264
Actually the first directive you used would work, but it would need to be in the correct place.
Order Allow,Deny
<Files something.php>
Allow from zzz.zzz.zzz.zzz
</Files>
Notice that I removed the deny from all as it's not required.
http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#order
Upvotes: 0
Reputation: 1747
I found my answer in an older post, one of the answers in here: .htaccess: how to restrict access to a single file by IP?, the correct is:
<Files something.php>
Order deny, allow
Deny from all
allow from zzz.zzz.zzz.zzz
</Files>
from the original I changed "Order allow, deny" to "Order deny, allow" and it works!
Upvotes: 1