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
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!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With