我需要排除正常htaccess的基本认证保护的一个网址(甚至更好的preFIX)。类似的 /回调/ myBank 或 /回调/. * 你有任何提示,该怎么办呢?
我不是在寻找的是如何排除的文件。 这必须是URL(因为这是一个基于PHP的框架解决方案,以及所有URL重定向与mod_rewrite的到的index.php)。因此,有在此URL没有文件。什么也没有。
其中一些网址是从其他服务仅仅是回调(没有IP不知道,所以我不能排除基于IP),他们可以不提示用户/密码。
目前的定义很简单,只要:
AuthName指令登录。
目录AuthGroupFile的/ dev / null的
与AuthType基本
的AuthUserFile /xxx/.htpasswd
需要有效的用户
解决方案
使用 SetEnvIf之后,你可以当请求开始与一些路径创建一个变量,然后使用满足任何
指令,以避免登录。
#设置environtment变量NOAUTH如果要求以/回调/
SetEnvIf之后REQUEST_URI ^ /回调/ NOAUTH = 1
#在auth块
AuthName指令请登录。
目录AuthGroupFile的/ dev / null的
与AuthType基本
的AuthUserFile /xxx/.htpasswd
#这里是我们允许/拒绝
订单拒绝,允许
满足任何
所有拒绝
需要有效的用户
从ENV = NOAUTH允许
指令的允许/拒绝大块表示,拒绝访问的 EVERYONE 的,除非有一个的有效的用户的(成功的基本认证登录)或者 NOAUTH 变量$设置。
I need to exclude one Url (or even better one prefix) from normal htaccess Basic Auth protection. Something like /callbacks/myBank or /callbacks/.* Do you have any hints how to do it?
What I'm not looking for is how to exclude a file. This has to be url (as this is solution based on PHP framework, and all urls are redirected with mod_rewrite to index.php). So there is no file under this url. Nothing.
Some of those urls are just callbacks from other services (No IP is not known so I cannot exclude based on IP) and they cannot prompt for User / Password.
Current definition is as simple as:
AuthName "Please login."
AuthGroupFile /dev/null
AuthType Basic
AuthUserFile /xxx/.htpasswd
require valid-user
解决方案
Using SetEnvIf, you can create a variable when the request starts with some path, then use the Satisfy Any
directive to avoid having to login.
# set an environtment variable "noauth" if the request starts with "/callbacks/"
SetEnvIf Request_URI ^/callbacks/ noauth=1
# the auth block
AuthName "Please login."
AuthGroupFile /dev/null
AuthType Basic
AuthUserFile /xxx/.htpasswd
# Here is where we allow/deny
Order Deny,Allow
Satisfy any
Deny from all
Require valid-user
Allow from env=noauth
The allow/deny chunk of directives says that deny access for EVERYONE, except when there is a valid-user (successful BASIC auth login) or if the noauth
variable is set.
相关推荐
最新文章