views:

373

answers:

3

Hi. I have a VPS and i'm trying to host several SVN projects. I'd like the URL paths to be like this:

http://svn.domain.com -> Welcome HTML page (at /var/www/svn.domain.com/httpdocs/index.php)
http://svn.domain.com/project1 -> Project 1 SVN Root
http://svn.domain.com/project2 -> Project 2 SVN Root
http://svn.domain.com/project3 -> Project 3 SVN Root

However, with the code below, The first thing (Welcome HTML page) doesn't show up, as the Location block takes precedence over the DocumentRoot.

Setting the Location block to <Location /repos> works, but then my URLs become http://svn.domain.com/repos/project1, which I do not like.

Any suggestions?

<VirtualHost *>
        ServerName svn.domain.com
        DocumentRoot /var/www/svn.domain.com/httpdocs
        <Location />
                DAV svn
                SVNParentPath /var/svn
                SVNIndexXSLT "/svnindex.xsl"

                AuthzSVNAccessFile /var/svn/access

                SVNListParentPath On
                # try anonymous access first, resort to real
                # authentication if necessary.
                Satisfy Any
                Require valid-user

                # how to authenticate a user
                AuthType Basic
                AuthName "Subversion repository"
                AuthUserFile /var/svn/passwd
        </Location>
</VirtualHost>

<Directory /var/svn>
        Allow from all
</Directory>
+1  A: 

you can use SVNPATH directive, however you have to set up three locations (each project needs its own)

Peter Parker
I was hoping I wouldn't have to do it this way, and that I was merely lacking in my Apache configuration know how :-/
CB
A: 

You could get around this without having to change your Apache configuration every time you add a new project by adding a subdomain for your SVN repositories. You'd end up with something like this:

<VirtualHost *>
    ServerName svn.domain.com
    DocumentRoot /var/www/svn.domain.com/httpdocs
    <Location /svn>
            DAV svn
            SVNParentPath /var/svn
            SVNIndexXSLT "/svnindex.xsl"

            AuthzSVNAccessFile /var/svn/access

            SVNListParentPath On
            # try anonymous access first, resort to real
            # authentication if necessary.
            Satisfy Any
            Require valid-user

            # how to authenticate a user
            AuthType Basic
            AuthName "Subversion repository"
            AuthUserFile /var/svn/passwd
    </Location>

    <Directory /var/svn>
    Allow from all </Directory>

    <Directory /var/www/svn.domain.com/httpdocs>
      # Doc. root directives here</Directory>

You'd then have to access your repositories with URLs of the form http://svn.domain.com/svn/project1/, but if you want to add project4 etc. all you have to do is add the new repository under /var/svn.

gareth_bowles
You mean 'subdirectory', not subdomain, and this is true, but it's what I was trying to avoid :). Thanks though.
CB
A: 

What about mod_rewrite? You could set up a folder for non-SVN stuff (http://example.com/info/), then use mod_rewrite to redirect requests for '/' or '/index.php' to '/info/index.php'. Would that work?

Gaurav
I believe I tried this solution and it failed. I don't know exactly why, I'm pretty sure it just didn't work (tm). I'll take another hack at it tomorrow and report back.
CB