我正在尝试使用查询字符串中某处的给定ID密码保护页面。我的.htaccess看起来像这样:
RewriteEngine On
RewriteCond %{QUERY_STRING} id=12
RewriteRule (.*) $1 [E=protected_uri:1]
Order Deny,Allow
AuthName "Protected"
AuthType Basic
AuthUserFile /blabla/.htpasswd
AuthGroupFile /
Require valid-user
Order allow,deny
Allow from all
Deny from env=protected_uri
Satisfy any
这适用于http://xy.com/?id=12,但它不适用于http://xy.com/index.php?id=12。对于第二个URL,不需要密码。
我不知道为什么这不起作用,因为RewriteCond-Line中的id = 12应该匹配id = 12的所有网址?
感谢您的帮助! 本