简体   繁体   English

当用户具有特定的Cookie SetEnvIf时,绕过.htaccess登录

[英]Bypass .htaccess login when user has a specific cookie SetEnvIf

This is how my .htaccess looks like: 这是我的.htaccess的样子:

AuthType Basic
AuthName "FORBIDDEN AREA"
AuthUserfile "../htdocs/site/.htpasswd"
AuthGroupFile /
Require valid-user

#Allow valid-user
Order Deny,Allow
Deny from all
SetEnvIf HTTP_COOKIE my_cookie_name norequire
Allow from env=norequire
Satisfy any

My user has a cookie, and if his cookie has a name "my_cookie_name" I would like that he bypasses the .htaccess login (authentication) so that he doesn't need to enter his username and password. 我的用户有一个cookie,并且如果他的cookie的名称为“ my_cookie_name”,我希望他绕过.htaccess登录(身份验证),这样就无需输入用户名和密码。 I tried with SetEnvIF but it does't seem to work, or am I doing something wrong. 我尝试了SetEnvIF,但它似乎不起作用,或者我做错了什么。 If anyone has some suggestion I would be grateful to hear it? 如果有人有任何建议,我将不胜感激吗?

Thanks 谢谢

You can use: 您可以使用:

SetEnvIfNoCase Cookie PHPSESSID=.* PASS=1

AuthType Basic
AuthName "FORBIDDEN AREA"
AuthUserfile "../htdocs/site/.htpasswd"
AuthGroupFile /
Require valid-user

#Allow valid-user
Order Deny,Allow
Deny from all
Allow from env=PASS
Satisfy any

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM