Skip to main content
 首页 » 编程设计

apache之.htaccess:如何通过 IP 限制对单个文件的访问

2025年02月15日22linjiqin

我已经查看了所有内容,但不断遇到有关目录级别 IP 限制的相同信息,通常看起来像这样:

Order Deny,Allow 
Deny from all 
Allow from 123.123.123.123 

是否可以将相同类型的访问限制绑定(bind)到页面/文档?

请您参考如下方法:

有关更新的 Apache 2.4 示例:

<Files file.html> 
    Require ip 123.123.123.123 
</Files> 

以下是有关其他选项和示例的更深入的文档: https://httpd.apache.org/docs/2.4/howto/access.html以及 <Files> 的文档指令: https://httpd.apache.org/docs/2.4/mod/core.html#files

Note that <Files> can be nested inside <Directory> sections to restrict the portion of the filesystem they apply to.