apache mod_rewrite <directory>优先于<location>的svn和trac </location> </directory>

时间:2012-05-05 15:41:54

标签: apache mod-rewrite trac

我有一个apache配置文件,

<VirtualHost *:443 >

    SSLEngine on
    SSLCertificateFile ...
    SSLCertificateKeyFile ...
    SSLCertificateChainFile ...
    SSLCACertificateFile ...


    ServerName www.etebaran.com
    ServerAlias www.etebaran.com etebaran.com 
    ServerAdmin webmaster@etebaran.com
    DocumentRoot /home/etebaran/domains/etebaran.com/private_html
    ScriptAlias /cgi-bin/ /home/etebaran/domains/etebaran.com/public_html/cgi-bin/

    UseCanonicalName OFF

    SuexecUserGroup etebaran etebaran
    CustomLog /var/log/httpd/domains/etebaran.com.bytes bytes
    CustomLog /var/log/httpd/domains/etebaran.com.log combined
    ErrorLog /var/log/httpd/domains/etebaran.com.error.log
    ErrorDocument 400 default
    ErrorDocument 401 default
    ErrorDocument 403 default
    ErrorDocument 404 default
    ErrorDocument 405 default
    ErrorDocument 408 default
    ErrorDocument 410 default
    ErrorDocument 411 default
    ErrorDocument 412 default
    ErrorDocument 413 default
    ErrorDocument 414 default
    ErrorDocument 415 default
    ErrorDocument 500 default
    ErrorDocument 501 default
    ErrorDocument 502 default
    ErrorDocument 503 default

<Location /svn>
    #Options -All
    DAV svn
    SVNPath /home/etebaran/svn/

    AuthzSVNAccessFile /home/etebaran/svn/conf/authz
    Satisfy Any
    Require valid-user
    AuthType Basic
    AuthName "Etebaran Repository"
    AuthUserFile /home/etebaran/svn/conf/.htpasswd
    SVNAutoversioning on 
</Location>
<Location /trac>
    SetHandler mod_python
    PythonHandler trac.web.modpython_frontend
    PythonOption TracEnv /home/etebaran/trac
    PythonOption TracUriRoot /trac
    Satisfy Any
</Location>
<LocationMatch "/trac/login">
    AuthType Basic
    AuthName "Etebaran Trac"
    AuthUserFile /home/etebaran/svn/conf/.htpasswd
    Require valid-user
</LocationMatch>
    <Directory /home/etebaran/domains/etebaran.com/private_html>
        Options +Includes -Indexes
        RewriteEngine On
        RewriteCond %{query_string} ^(.*)
        RewriteRule (.*) etebaran/_japp/controller.php?__r=$1&%1 [L]
        suPHP_Engine ON
        suPHP_UserGroup etebaran etebaran
    </Directory>
</VirtualHost>

问题是,<Directory>优先于<Location>,因此目录上的重写规则会覆盖位置。

奇怪的是,etebaran.com/svn仍然有效,但etebaran.com/trac由目录指令和位于那里的PHP框架处理。

我知道有一些讨厌的解决方法,但最新的是什么?

1 个答案:

答案 0 :(得分:1)

问题似乎是您的RewriteCond行。您的匹配模式为^(.*),基本上与任何相匹配。使用更详细的匹配模式以确保它与其他工具的URL不匹配。例如,!^/svn/.*的模式应匹配任何不以“/svn/”开头的网址。

您的Subversion和Trac安装似乎分别使用以“/svn/”和“/trac/”开头的网址。 PHP框架的URL是什么样的?它们也是以前缀开头,还是从网站的根目录提供?