当用户具有特定的Cookie SetEnvIf时,绕过.htaccess登录 [英] Bypass .htaccess login when user has a specific cookie SetEnvIf

查看:66
本文介绍了当用户具有特定的Cookie SetEnvIf时,绕过.htaccess登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的.htaccess的样子:

This is how my .htaccess looks like:

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

我的用户有一个cookie,并且如果他的cookie的名称为"my_cookie_name",我希望他绕过.htaccess登录(身份验证),这样他就不需要输入用户名和密码了.我尝试了SetEnvIF,但它似乎不起作用,或者我做错了什么.如果有人有任何建议,我将不胜感激吗?

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. I tried with SetEnvIF but it does't seem to work, or am I doing something wrong. If anyone has some suggestion I would be grateful to hear it?

谢谢

推荐答案

您可以使用:

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

这篇关于当用户具有特定的Cookie SetEnvIf时,绕过.htaccess登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆