我想知道下面的代码应该工作:
<LocationMatch "/(.*)([/])?(.*)"> Order allow,deny Allow from all AuthType Basic AuthName "Git" AuthUserFile /git/.htpasswd AuthGroupFile /git/.htgroup Require group $1 </LocationMatch>
我试图实现这个是要求基于第一个正则expression式variables的组。 因此,如果用户转到http://localhost/a-repository-name他必须在组a-repository-name中才能打开url。
出于某种原因,我不能得到这个代码的工作和Apache返回: Authorization of user **** to access /a-repository-name failed, reason: user is not part of the 'require'ed group(s).
我想这不符合Require group $1的正确variables。
这是正确的做法,或者我错过了什么?
LocationMatch不支持反向引用,你不能在2.4.8之前的版本中这样做。
根据Apache文档 ,现在支持…
从2.4.8开始,命名组和反向引用被捕获并写入环境,相应的名称以“MATCH_”为前缀,并以大写forms。 这允许在expression式和模块(如mod_rewrite)中引用URL的元素。 为了防止混淆,编号(未命名)的反向引用被忽略。 使用命名组代替。
<LocationMatch "^/combined/(?<sitename>[^/]+)"> require ldap-group cn=%{env:MATCH_SITENAME},ou=combined,o=Example </LocationMatch>