Andreas Linden
Andreas Linden

Reputation: 12721

svn per apache with mod_rewrite

I have the following virtuslhost for my subversion repository and i want to create a link which always points at the latest stable tag. i tried this using mod_rewrite. it is accepted by apache without any errors but wont work. i also tried to rewrite .* which seems not work (yes i restarted apache)

<VirtualHost svn.warsow-race.net>
    ServerAdmin             [email protected]
    ServerName              svn.warsow-race.net

    ErrorLog                /srv/svn/error.log
    CustomLog               /srv/svn/access.log combined

    RewriteEngine On
    RewriteRule ^/racesow0.5/latest-stable(.*) /racesow0.5/tags/0.5.4-stable$1

    <Location />
            DAV svn
            SVNParentPath /srv/svn
    </Location>

    <Location /racesow0.5>
            AuthType Basic
            AuthName "Racesow 0.5"
            AuthUserFile /srv/svn/racesow.passwd
            <LimitExcept GET OPTIONS PROPFIND REPORT>
                    Require valid-user
            </LimitExcept>
    </Location>
</VirtualHost>

the rewrite log says

(2) init rewrite engine with requested uri /racesow0.5/latest-stable/sdk
(3) applying pattern '^/racesow0.5/latest-stable(.*)' to uri '/racesow0.5/latest-stable/sdk'
(2) rewrite '/racesow0.5/latest-stable/sdk' -> '/racesow0.5/tags/0.5.4-stable/sdk'
(2) local path result: /racesow0.5/tags/0.5.4-stable/sdk
(2) prefixed with document_root to /htdocs/racesow0.5/tags/0.5.4-stable/sdk
(1) go-ahead with /htdocs/racesow0.5/tags/0.5.4-stable/sdk [OK]

but when calling i get a 404 not found

Upvotes: 0

Views: 930

Answers (2)

Peter Parker
Peter Parker

Reputation: 29715

This will not work as Subversion will do its request on top of the location and then involves some "magic" look into your access log to see what is actually requested:

/racesow0.5/!svn/vcc/[...]
/racesow0.5/!svn/bc/888/[...]

I do not know exactly how it works, but to simply "rewrite" the request will not work.

I would suggest to create a folder "/racesow0.5/latest-stable" and put an svn:external into this folder pointing to your latest release.

Upvotes: 1

Tim Stone
Tim Stone

Reputation: 19169

The mod_rewrite documentation (see "Per-directory Rewrites") indicates that you should avoid putting directives inside of a <Location> section, declaring it "unsupported". I'd have to check in with the source code to see what impact that actually has, but it's best to just avoid it.

I'd suggest trying to move your rules out into the <VirtualHost>, and then also PT (passthrough) the rewrite in case any other module needs proper access to the rewritten path:

<VirtualHost svn.warsow-race.net>
    ...
    ReweiteEngine On
    RewriteRule ^/racesow0.5/latest-stable(.*) /racesow0.5/tags/0.5.4-stable$1 [PT]
    ...
</VirtualHost>

Upvotes: 1

Related Questions