I have a bunch of projects on the same server. This server is hosting both the SVN repos and the actual web projects. I’d like to have this structure:
project1.server.com - with doc root to /var/www/html/project1/public
project2.server.com - with doc root to /var/www/html/project2/public
project3.server.com - with doc root to /var/www/html/project3/public
And be able to access every SVN repo with this URLs
svn.server.com/project1 - with repo root at /var/www/svn/project1/
svn.server.com/project2 - with repo root at /var/www/svn/project2/
svn.server.com/project3 - with repo root at /var/www/svn/project3/
My current configs are:
<VirtualHost *:80>
ServerName project1.server.com
DocumentRoot "/var/www/html/project1/public"
RewriteEngine off
<Location />
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(js|ico|gif|jpg|png|css)$ /index.php
</Location>
</VirtualHost>
# ... similar <VirtualHost> tags here for the other web subdomains
<VirtualHost *:80>
ServerName svn.server.com
<Location />
Deny from all
</Location>
<Location /project1>
Allow from all
AuthType Basic
AuthUserFile /etc/svn-auth-conf
Require valid-user
DAV svn
SVNPath /var/www/svn/project1
AuthName "Project 1 - Development Repository"
AuthzSVNAccessFile /etc/svn-acl-conf
</Location>
# ... similar <Location> tags for the other repos
</VirtualHost>
If I change the DocumentRoots to something different like /var/www/html/project1-site/public this works well, so I’m pretty sure that what’s happening is this:
It’s also possible that you have an object in the web root which has the same name as your repository URL. For example, imagine your web server’s document root is /var/www and your Subversion repository is located at /home/svn/repo. You then configure Apache to serve the repository at http://server.com/myrepo. If you then create the directory /var/www/myrepo/ this will cause a 301 error to occur.
But I would really like to keep the directory structure like I showed above. What should I do to get it working? I want to have it like this since it’s the tidier structure I could come up with. So ideas are also accepted!
You can try changing the port of the SVN v-host (I think SVN usually uses
3690). Right now you’re using the same root path (Location /) and same port (80) for both protocols, so Apache can’t differentiate the two kinds of requests.Some more info here: http://en.wikipedia.org/wiki/Apache_Subversion#Repository_access
Note that your SVN clients will also have to use this port. Not sure if that’s ok for you.