2013-02-27 89 views
3

我需要一些重寫幫助。重寫URL以匹配Locationmatch

有兩個規則需要被應用:1. 基地的RewriteCond上HTTP_USER_AGENT 2.添加路徑到URL,以配合LocationMatch

什麼我現在它被打破:

RewriteCond %{HTTP_USER_AGENT} ^git 
RewriteRule ^(.*)$ /git/$1 [L] 

刪除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> 

由於

回答

4

的解決方案是使用[PT]而不是[L]。