3

我需要一些帮助来重写。

有两个规则需要应用: 1. 基于 HTTP_USER_AGENT 的 RewriteCond 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

1 回答 1

4

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

于 2013-02-28T15:10:06.283 回答