【发布时间】:2011-07-02 22:47:07
【问题描述】:
我已经在我的 apache 服务器上创建了一个基于查询的身份验证,但是我从 apache 得到了一个奇怪的行为,并且找不到我的出路。这是 .htaccess 代码:
RewriteEngine on
RewriteCond %{QUERY_STRING} p=1
RewriteRule ^(.*)$ $1?map=$1 [E=authme:1]
Order deny,allow
Deny from env=authme
AuthType Basic
AuthName "Login Required"
AuthUserFile /var/www/test/.htpasswd
require valid-user
Satisfy any
我希望 apache 查看 p=1 的查询字符串。如果找到,则设置环境变量(authme=1)。这很好用!
我希望如果查询字符串中存在 p=1,则需要进行身份验证(从 env=authme 拒绝)。
如果从浏览器调用主索引文件(在我的情况下为 index.php),所有这些东西都非常有效,但如果调用同一目录中的其他文件,根本不起作用。
环境变量设置正确(我可以用PHP检查),但不需要认证。
我真的不明白为什么。任何帮助将不胜感激!
更多信息可以找到here
【问题讨论】:
标签: apache .htaccess mod-rewrite http-authentication