【发布时间】:2014-11-09 09:55:27
【问题描述】:
Windows Server 2003 R2 Standard x64 Edition Service Pack 2、Apache 2.4.4、PHP 5.4.16 (x86)
我的大多数目录都包含一个 index.php 文件,我已使用 httpd.conf 文件将其设置为 DirectoryIndex。
这是我的 httpd.conf 文件中的一些文本
DocumentRoot "c:/wamp/www"
<Directory "c:/wamp/www">
Options -Indexes
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
<Directory "C:/wamp/www/subdirectory">
Options -Indexes
DirectoryIndex index.php
Order deny,allow
Allow from all
</Directory>
<Files "index.php">
AuthType Basic
AuthName "srvname"
AuthUserFile "C:/wamp/.htpasswd"
Require valid-user
Order deny,allow
Allow from all
</Files>
上述配置导致 both servername/subdirectory/index.php 和 servername/index.php 提示输入用户名和密码。
尝试使用 Files 指令更具体,如下所示,导致 既不 servername/subdirectory/index.php 也不 servername/index.php 提示输入密码。
<Files "C:/wamp/www/index.php">
AuthType Basic
AuthName "srvname"
AuthUserFile "C:/wamp/.htpasswd"
Require valid-user
Order deny,allow
Allow from all
</Files>
我真正想要完成的只是密码保护我的 WampServer 配置页面。有人可以告诉我如何在 httpd.conf 中专门在 C:/wamp/www/index.php 上使用 Files 指令而不锁定我所有的 index.php 页面吗?
【问题讨论】: