【问题标题】:Rewrite URL to match Locationmatch重写 URL 以匹配 Locationmatch
【发布时间】:2013-02-13 19:21:23
【问题描述】:

我需要一些帮助来重写。

有两条规则需要应用: 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>

谢谢

【问题讨论】:

    标签: apache rewrite


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-10
      • 1970-01-01
      相关资源
      最近更新 更多