views:

24

answers:

2

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

A: 

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>
Tim Stone
already tried that but with no effect
zolex
@zolex - Hm..Maybe you should setup a [`RewriteLog`](http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritelog) to see if `mod_rewrite` is being properly invoked in the first place. Currently you're getting 404s when you try to view `/racesow0.5/latest-stable`?
Tim Stone
i just did that and updated my question
zolex
+1  A: 

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.

Peter Parker
that sounds nice, i'll try
zolex
hm can't make it work
zolex
added a folder /repp/latest, and on this folder added svn:externals latest URL, then you can checkout /latest and get a fodler stable containing the target :)
zolex
you mean you get something like /wc/latest/tag_1.5.x/further/src ?
Peter Parker
i do "svn export .../latest-stable ." and get the contents from the tag in ./latest-stable
zolex
just do it "svn export http:// svn.warsow-race.net/racesow0.5/latest-stable ." (use . as destination! it will create another folder latest-stable in it) what you get is exactly http:// svn.warsow-race.net/racesow0.5/tags/0.5.4-stable
zolex
what do you want to get? The external will always create a subfolder with the name you provided next to the URL inside the svn:externals property.
Peter Parker