Subversion的Repository列表完美解决方案
授权方式:署名,非商业用途,保持一致,转载时请务必以超链接(http://www.fwolf.com/blog/post/60)的形式标明文章原始出处和作者信息及本声明。我的SVN项目都放在h:/svn下,在Apache中只是把这个目录设置成了虚拟目录,这样我可以方便的通过http://localhost/svn/project1访问这个目录下的所有Repository,但如果我想访问http://localhost/svn/,是得不到所有Repository列表的,只是一个403 Forbidden错误,在TortorseSVN的帮助中有这么一篇文章中提到了解决的方法,下面是我的具体实施和一点心得。
SVN在Apache中的配置段一般都用<Location>,我尝试过使用<Directory>,好像也可以,但不管用那个,在配置中无法使用AllowOverride指令,也就是说.htaccess文件无法使用。因此,若想把http://localhost/svn/转向到调用其它文件,只能使用Rewrite module,并且必须写在<Location>段之外。我就是在这里试了N久 :(。
(Apache一般配置和PHP、Rewrite module安装略过)
为了方便管理,用于显示Repository列表的PHP文件放在了h:/svn/svntools/目录,也就是在SVN的根目录下 :-)。因此,Apache中的这段配置如下:
Alias /svntools "h:/svn/svntools"
RewriteEngine on
RewriteRule ^/svn/$ /svntools/svn_index.php [PT]
<Location /svn>
DAV svn
SVNParentPath h:/svn
</Location>
先用Alias定义到h:/svn/svntools的虚拟目录,这样就可以访问到svn_index.php文件了,然后打开RewriteEngine,使用RewriteRule将到/svn/的访问重定向到/svntools/svn_index.php文件,通过执行这个文件就会产生Repository列表了;最后是SVN虚拟目录的配置。
![[Bloglines]](http://www.fwolf.com/blog/wp-content/plugins/bookmarkify/bloglines.png)
![[co.mments]](http://www.fwolf.com/blog/wp-content/plugins/bookmarkify/comments.png)
![[del.icio.us]](http://www.fwolf.com/blog/wp-content/plugins/bookmarkify/delicious.png)
![[Digg]](http://www.fwolf.com/blog/wp-content/plugins/bookmarkify/digg.png)
![[diigo]](http://www.fwolf.com/blog/wp-content/plugins/bookmarkify/diigo.png)
![[Facebook]](http://www.fwolf.com/blog/wp-content/plugins/bookmarkify/facebook.png)
![[Furl]](http://www.fwolf.com/blog/wp-content/plugins/bookmarkify/furl.png)
![[Google]](http://www.fwolf.com/blog/wp-content/plugins/bookmarkify/google.png)
![[MySpace]](http://www.fwolf.com/blog/wp-content/plugins/bookmarkify/myspace.png)
![[Reddit]](http://www.fwolf.com/blog/wp-content/plugins/bookmarkify/reddit.png)
![[Rojo]](http://www.fwolf.com/blog/wp-content/plugins/bookmarkify/rojo.png)
![[Slashdot]](http://www.fwolf.com/blog/wp-content/plugins/bookmarkify/slashdot.png)
![[StumbleUpon]](http://www.fwolf.com/blog/wp-content/plugins/bookmarkify/stumbleupon.png)
![[Technorati]](http://www.fwolf.com/blog/wp-content/plugins/bookmarkify/technorati.png)
![[Windows Live]](http://www.fwolf.com/blog/wp-content/plugins/bookmarkify/windowslive.png)
![[Yahoo!]](http://www.fwolf.com/blog/wp-content/plugins/bookmarkify/yahoo.png)
![[Email]](http://www.fwolf.com/blog/wp-content/plugins/bookmarkify/email.png)