我在我的httpd.conf文件中有以下内容:
<Directory "/www"> Options Indexes FollowSymLinks AllowOverride AuthConfig FileInfo Options=Indexes,Limit Order allow,deny Allow from all </Directory>
接下来,我有一个目录ChatLogs位于服务器根目录下,一个.htaccess文件定义如下:
Allow from all AuthName "Restricted Area" AuthType Basic AuthUserFile /www/.htpasswd AuthGroupFile /dev/null Require valid-user
当我尝试访问该目录时,服务器日志中出现以下500服务器错误( 10.109.1.92是我的Intranet IP):
[alert] [client 10.109.1.92] /www/ChatLogs/.htaccess: allow not allowed here
我明白,这是因为在.htaccess文件中的以下声明:
Allow from all
但有人可以解释为什么不允许Allow指令 ? 我稍后想要限制对某些IP地址范围的访问; 如果可以放在单独的目录中,而不是在httpd.conf文件中设置它们,则会更喜欢。
因为在限制之前你有一个逗号。 这使得apacheparsing它,就像它是选项的一部分,而不是一个单独的重写。 像这样想:
AllowOverride AuthConfig FileInfo Options=Indexes,Limit
你想要的是相反的
AllowOverride AuthConfig FileInfo Limit Options=Indexes
Apache核心文档中有更多的信息。