Apache .htaccess显示索引,仅在登录时授予文件访问权限
我尝试使用.htaccess保护目录中的.html文件。 目录索引仍应为visibe,无需登录。 我创建了以下内容: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
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
结合起来。