Short answer: Use the PT
flag on your RewriteRule.
First, a little Apache backstory. When Apache receives a request, it goes though a process of mapping that request to the local storage. After that, Apache actually has two pieces of data on what you requested. The request url, and the file path. So a request for /svn/blah
is translated into /var/www/vhosts/myserver.com/html/svn/blah
and that path is stored separately. mod_rewrite lets you tweak this behavior to route urls where you want.
Now, the two RewriteRules you have there are implicitly doing different things.
The first one you have there is a rewrite. It takes a url like /svn/blah
and instead of using the behavior above, it maps it as if you actually requested /svn/myrepo/blah
, so the resulting filepath would be /var/www/vhosts/myserver.com/html/svn/myrepo/blah
. However, and here's the sticking point, it does not modify the requested url. The request url is still /svn/blah
, apache just now thinks that file is to be found at .../svn/myrepo/blah
rather than .../svn/blah
.
Why does this matter you ask? Because the subversion module doesn't use the filepath. It looks at the request url. So apache and mod_rewrite just wasted time doing all that, because mod_dav_svn just ignores it. What you need is for mod_rewrite to change the request url. And that's what PT
does. It modifies both the request url and the file path, so later when it gets to mod_dav_svn, it will see the changed url.
The second one is a redirect. Since the substitution starts with http://
and apache doesn't have a virtualhost named 192.168.0.1
, it assumes you actually meant to put an R
in your flags, since it can't translate that into a filepath. That is sending back a "Hey, it's over here" message to the subversion client, and it's making another request for it.
Now, having said all that, you're never going to have more than one repository on there anyway with this setup unless you do something to force mod_rewrite to skip the urls of the other repositories. mod_rewrite will cheerfully change /svn/bignewproject/blah
into /svn/myrepo/bignewproject/blah
for you every time. You could add a rule before the RewriteRule you have such as:
RewriteRule ^/svn/(myrepo|myotherrepo|coolproject|stuff|etc)/ - [S=1]
That will cause it to skip the next rule. However, you're going to be updating it by hand from here on out. You might be able to pull off something automated with some RewriteCond magic, but it'll probably be tricky. I'm not really familiar with that, so someone else would have to help you out there.
If this is only used by a small group of people, then you might be better off skipping this rewriting stuff entirely and just update everyone's working copies. svn switch --relocate
is meant specifically for situations where the repos is moved and you just want to update your working copy without checking it out again. I understand there are situations where this simply isn't feasible though.
The documentation states that the directories under SVNParentPath have to be repositories, so no looking through all subdirectories.
You might be able to make script though, that would output several Location-blocks matching the parent folders of SVN repositories.
Best Answer
Unfortunately CentOS 5's subversion is quite old, 1.4.2, whereas Fedora 10's is newer, 1.5.4. The fsfs format must have changed between the two (look for a version file in the repository directory) and your older subversion on CentOS can't read the newer version generated on 1.5.4.
You have two options:
Install a temporary copy of 1.5.4 or later (or e.g. set up a Fedora 10 VM to use the copy there), use
svnadmin dump
from 1.5.4 to back up the repository then load this into a new repository usingsvnadmin load
with the 1.4.2 tools. This may be slow, and you'll also have to copy over any hooks etc. You'll also lose the server-side support for svn:mergeinfo attributes.Install a newer version of subversion on your machine. You can either build this yourself - getting a Fedora SRPM is a good start, although it will usually need a few fix-ups - or you can set up your system to update from RPMForge, either in its entirety or just for subversion and its dependencies - and install their up-to-date builds of 1.6.x. You'll get all the improvements of 1.6 and keep the svn:mergeinfo attribute support, but you'll no longer have a strictly-RHEL-5-compatible system (if you're bothered about that). For future note: as in the discussion below you must restart apache, e.g.
/sbin/service httpd restart
, after updating the installed subversion.Good luck!