开发者

How to prevent access to a single file based on IP using .htaccess?

开发者 https://www.devze.com 2022-12-08 02:07 出处:网络
All the resources I\'ve read explain how to prevent access to an entire directory based on IP but don\'t explain how to do this for a single file.

All the resources I've read explain how to prevent access to an entire directory based on IP but don't explain how to do this for a single file.

This is what is used to protect a directory:

<Limit GET POST PUT>
 order deny,allow
 deny from all
 allow from 123.456.78.910
</Limit>

Here only the IP 123.456.78.910 will have access to the directory in which that rule is placed. But the question again is: how to do this for a开发者_运维技巧 single file?


You could use this :

<Files foo.html>
    Order deny, allow
    Deny from all
    Allow from 123.456.78.910
</Files>

By the way, do not use <Limit GET POST PUT> to deny access to files, it is a big security hole with most Apache configurations.

0

精彩评论

暂无评论...
验证码 换一张
取 消