问题:我在/var/www/files/下有一些文件,我希望它们可以从特定的 IP 地址访问而无需用户/密码。但是,我希望任何其他 IP 地址都应该需要登录才能访问。
这是在我的 httpd.conf 中:
<Directory /var/www/files/>
Order deny,allow
Deny from all
Allow from 192.168
AuthUserFile /etc/apache2/basic.pwd
AuthName "Please enter username and password"
AuthType Basic
Require user valid-user
</Directory>
但是,如果我理解正确,这意味着来自 192.168.* 的任何客户端都可以访问该目录,但需要有效用户才能查看其内容。任何其他 IP 地址都将被拒绝。对?
先感谢您。
最佳答案
编辑 :这可能是可以接受的答案,但很旧。对于新的 Apache 安装,请使用 Brians answer here
添加这个:Satisfy Any
(这意味着应该通过这两个中的任何一个)。
语法是:
Require valid-user
或者:
Require user <userid>
关于Apache 基本身份验证(允许的除外),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4102763/