使用SVNParentPath的時(shí)候,直接訪問ParentPath的時(shí)候,總是得到以下錯(cuò)誤提示:
403 Forbidden
Forbidden
You don't have permission to access /svn/ on this server.
下面的辦法可以搞定它:
一、首先,Subversion1.3及以后版本支持SVNListParentPath ON,之前的版本只能使用PHP自己做。
二、Location 設(shè)置中最后要加上/,應(yīng)該是<Location /svn/>而不是<Location /svn>否則可能不能訪問。
三、通過“http://localhost/svn/” 來訪問倉庫列表,如果想讓“http://localhost/svn”也起作用的話,需要在</Location>的后面增加重定向的設(shè)置:RedirectMatch ^(/svn)$ $1/ ,當(dāng)然也可以采用RewriteEngine之類的辦法。
四、修改后的httpd.conf的對(duì)應(yīng)部分如下:
<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 "服務(wù)器需要身份驗(yàn)證:"
# 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的幫助文件中有詳細(xì)描述:
<html>
<head>
<title>Subversion Repositories</title>
</head>
<body>
<h2>Subversion Repositories</h2>
<p>
<?php
$svnparentpath = "C:/svn";
$svnparenturl = "/svn";
$dh = opendir( $svnparentpath );
if( $dh ) {
while( $dir = readdir( $dh ) ) {
$svndir = $svnparentpath . "/" . $dir;
$svndbdir = $svndir . "/db";
$svnfstypefile = $svndbdir . "/fs-type";
if( is_dir( $svndir ) && is_dir( $svndbdir ) ) {
echo "<a href=\"" . $svnparenturl . "/" .
$dir . "\">" . $dir . "</a>\n";
if( file_exists( $svnfstypefile ) ) {
$handle = fopen ("$svnfstypefile", "r");
$buffer = fgets($handle, 4096);
fclose( $handle );
$buffer = chop( $buffer );
if( strcmp( $buffer, "fsfs" )==0 ) {
echo " (FSFS) <br />\n";
} else {
echo " (BDB) <br />\n";
}
} else {
echo " (BDB) <br />\n";
}
}
}
closedir( $dh );
}
?>
</p>
</body>
</html>
Save the lines above to a file svn_index.php and store that file in your web root folder. Next you have to tell Apache to show that page instead of the error:
Uncomment (remove the '#' char) from the following line in your Apache config file:
#LoadModule rewrite_module modules/mod_rewrite.so
Add the following lines just below your <Location> block where you define your Subversion stuff:
RewriteEngine on
RewriteRule ^/svn$ /svn_index.php [PT]
RewriteRule ^/svn/$ /svn_index.php [PT]
RewriteRule ^/svn/index.html$ /svn_index.php [PT] 六、URL重寫的若干非mod_rewrite方法 原文出處:
http://www.chinaunix.net 作者:HonestQiao 發(fā)表于:2005-09-23 23:40:16 1、Alias:重寫到本地路徑
可以使用Alias把一個(gè)指定的Url重寫到某一固定的本地路徑
Alias /test/ /home/www/test/
那么對(duì)
http://..../test/ 將對(duì)應(yīng)了/home/www/test/
注意:Alias必須是一一對(duì)應(yīng)的,/test/將不對(duì)/test起作用。
2、AliasMatch:重寫到本地路徑
與Alias類似,但是可以使用正則表達(dá)式
AliasMatch ^/test(.*) /home/www/test$1
在不需要很復(fù)雜的URL重寫時(shí),完全可以使用以上的幾條指令來進(jìn)行。