use*_*948 3 apache url-rewriting
我需要一些重写方面的帮助。
需要应用两个规则: 1. 将 RewriteCond 基于 HTTP_USER_AGENT 2. 添加 URL 路径以与 LocationMatch 匹配
我现在所拥有的已损坏:
RewriteCond %{HTTP_USER_AGENT} ^git
RewriteRule ^(.*)$ /git/$1 [L]
Run Code Online (Sandbox Code Playgroud)
删除 RewriteRule 并立即查询路径工作正常,但使用此规则运行会使 apache “无法找到文件”。
匹配是一个 LocationMatch <LocationMatch "/git/">,所以我不确定 RewriteRule 是否可以指向它?
完整配置:
<VirtualHost *:80>
DocumentRoot /home/subgit/repos
<Directory /home/subgit/repos>
Options None
AllowOverride none
Order allow,deny
Allow from all
</Directory>
CustomLog /home/subgit/logs/access_log combined
SuexecUserGroup subgit subgit
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^git
RewriteRule ^(.*)$ /git/$1 [L]
RewriteCond %{QUERY_STRING} service=git-receive-pack [OR,NC]
RewriteCond %{REQUEST_URI} ^/git/.*/git-receive-pack$ [NC]
RewriteRule .* - [E=AUTHREQUIRED:yes]
ScriptAlias /git/ /home/subgit/bin/gitolite-suexec-wrapper.sh/
<LocationMatch "/git/">
Order Allow,Deny
Deny from env=AUTHREQUIRED
Allow from all
Satisfy Any
AuthType Basic
AuthName "subgit"
AuthBasicProvider file
AuthUserFile /home/subgit/etc/subgit
Require valid-user
</LocationMatch>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
谢谢