【问题标题】:.htaccess File isn´t working..htaccess 文件不工作。
【发布时间】:2017-04-20 21:55:46
【问题描述】:

我想用密码保护整个 /var/www/html/* 区域,但排除一个文件。 我试过这个代码:

<Files *.*>
AuthType Basic
AuthName "Service-Login"
AuthUserFile /path/tomypasswdfile/...
Require valid-user
</Files>

<Files /index.alternetive.php>
#Order allow,deny
Require all granted
#Allow from All
#Allow from env=allow
#Satisfy any

</Files>

登录功能正常,但适用于所有文件,包括“index.alternative.php”-File。

我的 apache2 在 Ubuntu-Xenial 上运行。

非常感谢

【问题讨论】:

    标签: apache .htaccess apache2 password-protection


    【解决方案1】:

    Files 不适用于路径名,而只能用于文件名。如果你想要一个特定的路径,你必须将它包含在一个 Directory 指令中,或者将它放在它所属的 .htaccess 中。在您的情况下,这似乎是根目录

    AuthType Basic
    AuthName "Service-Login"
    AuthUserFile /path/tomypasswdfile/...
    Require valid-user
    
    <Files index.alternetive.php>
    Require all granted
    </Files>
    

    还要看拼写,例如alternetivealternative.

    【讨论】:

      【解决方案2】:

      文件名是你的问题。将其更改为 index_alternative.php 之类的内容,它应该适合您。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-05-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-07-14
        • 1970-01-01
        • 2011-12-15
        • 2015-02-21
        相关资源
        最近更新 更多