Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 绕过特定URI(包括查询字符串)的.htaccess授权_Php_Apache_.htaccess_Authorization - Fatal编程技术网

Php 绕过特定URI(包括查询字符串)的.htaccess授权

Php 绕过特定URI(包括查询字符串)的.htaccess授权,php,apache,.htaccess,authorization,Php,Apache,.htaccess,Authorization,我有一个基于各种查询字符串加载的PHP web应用程序。我需要应用程序要求身份验证,除非传递了特定的查询字符串 例如,如果URL为example.com/app/?Setting1=true 我想强制认证 但是,如果URL为example.com/app/?Setting1=true&Setting2=true 我想绕过身份验证 使用setenif Request_URI,我已经接近我想要的了,但是我不确定如何将查询字符串变量包含到Request_URI中 SetEnvIf Request_UR

我有一个基于各种查询字符串加载的PHP web应用程序。我需要应用程序要求身份验证,除非传递了特定的查询字符串

例如,如果URL为example.com/app/?Setting1=true 我想强制认证

但是,如果URL为example.com/app/?Setting1=true&Setting2=true 我想绕过身份验证

使用setenif Request_URI,我已经接近我想要的了,但是我不确定如何将查询字符串变量包含到Request_URI中

SetEnvIf Request_URI "(/app/test)$" allow

Order Deny,Allow

AuthType Basic
AuthName "Restricted Area"
AuthUserFile /home/path/.htpasswd
AuthGroupFile /dev/null

#Allow valid-user
Deny from all
Allow from env=allow
Satisfy any
我想要这样的东西:

SetEnvIf Request_URI "(/app/?Setting1=true&Setting2=true)$" allow

Order Deny,Allow

AuthType Basic
AuthName "Restricted Area"
AuthUserFile /home/path/.htpasswd
AuthGroupFile /dev/null

#Allow valid-user
Deny from all
Allow from env=allow
Satisfy any
非常感谢您的建议。

请重新编写引擎
RewriteEngine On
SetEnvIf Request_URI ".*" allow=0
RewriteCond %{QUERY_STRING} ^(?:.*[&?])?Setting1=true&Setting2=true$
RewriteRule ^ - [E=allow:1]
RewriteCond %{QUERY_STRING} ^(?:.*[&?])?Setting2=true&Setting1=true$
RewriteRule ^ - [E=allow:1]
<If "%{ENV:allow} == '0'">
        AuthUserFile /home/path/.htpasswd
        AuthType Basic
        AuthName "Restricted Access"
        Require user valid-user
</If>
SetEnvIf请求\u URI“*”允许=0 RewriteCond%{QUERY_STRING}^(?:.[&?])?设置1=true&设置2=true$ 重写规则^-[E=允许:1] 重写cond%{QUERY_STRING}^(?:.[&?])?设置2=true&设置1=true$ 重写规则^-[E=允许:1] AuthUserFile/home/path/.htpasswd AuthType Basic AuthName“受限访问” 需要用户有效用户
注:

  • setenif不支持查询字符串参数。请参考下面的链接

还可以使用mod_rewrite模块设置环境变量: