【问题标题】:.htaccess Require valid-user [except from localhost].htaccess 需要有效用户 [localhost 除外]
【发布时间】:2012-02-29 03:48:52
【问题描述】:

我正在尝试对目录进行密码保护,但来自 localhost 的请求除外。 我的 .htaccess 看起来像这样:

AuthName "Login"
AuthType Basic
AuthUserFile /PATH/.htpasswd
Require valid-user
Allow from 127.0.0.1
Allow from ::1
Satisfy Any


RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

ErrorDocument 404 /index.php

如果我删除 Allow 和 Satisfy 语句,目录将得到正确保护。当我添加允许(一个或两个)并满足任何时,它会生成 500 错误。日志说:

/PATH/.htaccess: allow not allowed here

有什么线索吗?

【问题讨论】:

    标签: .htaccess


    【解决方案1】:

    如果您有权访问服务器配置文件,请检查:AllowOverride 查看允许哪些指令。


    AllowOverride All
    

    将允许所有指令。

    更多信息请访问:AllowOverride Directive Apache Docs

    【讨论】:

    • 不起作用。根据 Apache Docs AllowOverride 仅适用于 部分。 Apache 响应“/etc/apache2/apache2.conf 第 164 行的语法错误:此处不允许 AllowOverride”。我想要 .htaccess 文件中的设置,而不是 部分所在的 .conf 文件。有可能吗?
    猜你喜欢
    • 2015-04-26
    • 2016-05-13
    • 2013-05-04
    • 2013-01-15
    • 1970-01-01
    • 2013-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多