利用SVNListParentPath增加http浏览仓库根目录的功能

配置SVNListParentPath实现仓库根目录访问
本文介绍了如何解决访问SVNParentPath时出现403 Forbidden错误的问题。通过启用SVNListParentPath选项,配置DAV、SVNParentPath、授权设置,并使用RedirectMatch或RewriteEngine进行URL重定向,可以成功访问仓库列表。同时,对于Subversion1.3以前的版本,可以使用PHP脚本来自定义列表显示。

使用SVNParentPath的时候,直接访问ParentPath的时候,总是得到以下错误提示:

403 Forbidden

Forbidden

You don't have permission to access /svn/ on this server.

下面的办法可以搞定它:

一、首先,Subversion1.3及以后版本支持SVNListParentPath ON,之前的版本只能使用PHP自己做。

二、Location 设置中最后要加上/,应该是<Location /svn/>而不是<Location /svn>否则可能不能访问。

三、通过“http://localhost/svn/” 来访问仓库列表,如果想让“http://localhost/svn”也起作用的话,需要在</Location>的后面增加重定向的设置:RedirectMatch ^(/svn)$ $1/  ,当然也可以采用RewriteEngine之类的办法。

四、修改后的httpd.conf的对应部分如下:

<Location /svn/>
    DAV svn
    SVNListParentPath on
    SVNParentPath e:/svn
#    SSLRequireSSL                 #指定该目录只能通过SSL操作
#    SVNPathAuthz off

    AuthzSVNAccessFile e:/ca/access/file
   
    #try anonymous access first,resort to real
    #authentication if necessary.
    #Satisfy Any
    Require valid-user
   
    #how to authenticate a user
    AuthType Basic
    AuthName "服务器需要身份验证:"
#    AuthUserFile e:/ca/access/svn-auth-file

  AuthMySQLHost localhost
  AuthMySQLUser Bugfree
  AuthMySQLPassword mandarin
  AuthMySQLDB BugFree
  AuthMySQLUserTable BugUser
  AuthMySQLNameField UserName
  AuthMySQLPasswordField UserPassword
#  AuthMySQLMD5Passwords On
  AuthMySQLPwEncryption md5
  
</Location>

RedirectMatch ^(/svn)$ $1/

五、如果使用Subversion1.3以前的版本,或需要定制列表显示的话,可以自己写php脚本来控制仓库列表的显示,TotoiseSVN的帮助文件中有详细描述:

2、AliasMatch:重写到本地路径
与Alias类似,但是可以使用正则表达式
AliasMatch ^/test(.*) /home/www/test$1

3、Redirect :重写到网址
Redirect /test/
http://....../test2/

4、RedirectMatch :重写到网址
与Redirect类似,但是可以使用正则表达式
Redirect /test(.*)
http://....../test2$1

在不需要很复杂的URL重写时,完全可以使用以上的几条指令来进行。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值