【问题标题】:How to use httpd.conf to lock down ONLY index.php at the root, not index.php files in subdirectories如何使用 httpd.conf 仅锁定根目录中的 index.php,而不锁定子目录中的 index.php 文件
【发布时间】: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 页面吗?

【问题讨论】:

    标签: php apache


    【解决方案1】:

    检查你的 apache.conf 文件,它应该有这个:

    <Files ~ "^\.ht">
        Order allow,deny
        Deny from all
        Satisfy all
    </Files>
    

    这就是到处隐藏以“.ht”开头的文件的东西。

    【讨论】:

      猜你喜欢
      • 2014-05-15
      • 1970-01-01
      • 1970-01-01
      • 2013-12-31
      • 2012-10-23
      • 2017-01-12
      • 2013-04-10
      • 2013-03-06
      • 1970-01-01
      相关资源
      最近更新 更多