Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache .htaccess显示索引,仅在登录时授予文件访问权限_Apache_.htaccess_Security - Fatal编程技术网

Apache .htaccess显示索引,仅在登录时授予文件访问权限

Apache .htaccess显示索引,仅在登录时授予文件访问权限,apache,.htaccess,security,Apache,.htaccess,Security,我尝试使用.htaccess保护目录中的.html文件。 目录索引仍应为visibe,无需登录。 我创建了以下内容: Order allow,deny AuthType Basic AuthName "Secured Area - Enter password!" AuthUserFile .htusers Options +Indexes IndexOptions HtmlTable FancyIndexing IconsAreL

我尝试使用.htaccess保护目录中的.html文件。 目录索引仍应为visibe,无需登录。 我创建了以下内容:

Order allow,deny
AuthType Basic
AuthName "Secured Area - Enter password!"
AuthUserFile .htusers                     

Options +Indexes
IndexOptions HtmlTable FancyIndexing IconsAreLinks SuppressRules SuppressSize
IndexIgnore ..

<Files "(\.htaccess|\.htusers)">
        Deny from all
</Files>

<Files "(.*\.html)">
        Require valid-user
</Files>
命令允许,拒绝
AuthType Basic
AuthName“安全区域-输入密码!”
AuthUserFile.htusers
选项+索引
IndexOptions HtmlTable FancyIndexing IconsAreLinks SuppressRules SuppressSize
IndexIgnore。。
全盘否定
需要有效用户

但有了它,一切都被禁止了。我尝试了几种组合,但都没有成功。也许有人能帮上忙?

我发现了问题所在。上述配置中的用户文件必须位于根目录中。这就解决了问题。

或者使用
FilesMatch
和一个否定表达式,该表达式不包括
index.html
,或者添加一个专门针对
index.html
Files
指令,在其中指定
Allow
,并使用
expect
将其与
Require
结合起来。