I have a VPS and i'm trying to host several SVN projects. I'd like the URL paths to be like this:
我有一个VPS,我正在尝试举办几个SVN项目。我希望URL路径是这样的:
http://svn.domain.com -> Welcome HTML page (at /var/www/svn.domain.com/httpdocs/index.php)
http://svn.domain.com/project1 -> Project 1 SVN Root
http://svn.domain.com/project2 -> Project 2 SVN Root
http://svn.domain.com/project3 -> Project 3 SVN Root
However, with the code below, The first thing (Welcome HTML page) doesn't show up, as the Location block takes precedence over the DocumentRoot.
但是,使用下面的代码,第一件事(欢迎HTML页面)不会显示,因为Location块优先于DocumentRoot。
Setting the Location block to <Location /repos>
works, but then my URLs become http://svn.domain.com/repos/project1
, which I do not like.
将位置块设置为
Any suggestions?
<VirtualHost *>
ServerName svn.domain.com
DocumentRoot /var/www/svn.domain.com/httpdocs
<Location />
DAV svn
SVNParentPath /var/svn
SVNIndexXSLT "/svnindex.xsl"
AuthzSVNAccessFile /var/svn/access
SVNListParentPath On
# try anonymous access first, resort to real
# authentication if necessary.
Satisfy Any
Require valid-user
# how to authenticate a user
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /var/svn/passwd
</Location>
</VirtualHost>
<Directory /var/svn>
Allow from all
</Directory>
3 个解决方案
#1
you can use SVNPATH directive, however you have to set up three locations (each project needs its own)
您可以使用SVNPATH指令,但是您必须设置三个位置(每个项目都需要自己的)
#2
You could get around this without having to change your Apache configuration every time you add a new project by adding a subdomain for your SVN repositories. You'd end up with something like this:
每次添加新项目时都可以通过为SVN存储库添加子域来更改Apache配置,从而解决这个问题。你最终得到这样的东西:
<VirtualHost *>
ServerName svn.domain.com
DocumentRoot /var/www/svn.domain.com/httpdocs
<Location /svn>
DAV svn
SVNParentPath /var/svn
SVNIndexXSLT "/svnindex.xsl"
AuthzSVNAccessFile /var/svn/access
SVNListParentPath On
# try anonymous access first, resort to real
# authentication if necessary.
Satisfy Any
Require valid-user
# how to authenticate a user
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /var/svn/passwd
</Location>
<Directory /var/svn>
Allow from all </Directory>
<Directory /var/www/svn.domain.com/httpdocs>
# Doc. root directives here</Directory>
You'd then have to access your repositories with URLs of the form http://svn.domain.com/svn/project1/, but if you want to add project4 etc. all you have to do is add the new repository under /var/svn.
然后,您必须使用http://svn.domain.com/svn/project1/形式的URL访问您的存储库,但是如果您要添加project4等,您只需在/下添加新存储库VAR / SVN。
#3
What about mod_rewrite? You could set up a folder for non-SVN stuff (http://example.com/info/), then use mod_rewrite to redirect requests for '/' or '/index.php' to '/info/index.php'. Would that work?
mod_rewrite怎么样?您可以为非SVN设置一个文件夹(http://example.com/info/),然后使用mod_rewrite将'/'或'/index.php'的请求重定向到'/info/index.php' 。那会有用吗?
#1
you can use SVNPATH directive, however you have to set up three locations (each project needs its own)
您可以使用SVNPATH指令,但是您必须设置三个位置(每个项目都需要自己的)
#2
You could get around this without having to change your Apache configuration every time you add a new project by adding a subdomain for your SVN repositories. You'd end up with something like this:
每次添加新项目时都可以通过为SVN存储库添加子域来更改Apache配置,从而解决这个问题。你最终得到这样的东西:
<VirtualHost *>
ServerName svn.domain.com
DocumentRoot /var/www/svn.domain.com/httpdocs
<Location /svn>
DAV svn
SVNParentPath /var/svn
SVNIndexXSLT "/svnindex.xsl"
AuthzSVNAccessFile /var/svn/access
SVNListParentPath On
# try anonymous access first, resort to real
# authentication if necessary.
Satisfy Any
Require valid-user
# how to authenticate a user
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /var/svn/passwd
</Location>
<Directory /var/svn>
Allow from all </Directory>
<Directory /var/www/svn.domain.com/httpdocs>
# Doc. root directives here</Directory>
You'd then have to access your repositories with URLs of the form http://svn.domain.com/svn/project1/, but if you want to add project4 etc. all you have to do is add the new repository under /var/svn.
然后,您必须使用http://svn.domain.com/svn/project1/形式的URL访问您的存储库,但是如果您要添加project4等,您只需在/下添加新存储库VAR / SVN。
#3
What about mod_rewrite? You could set up a folder for non-SVN stuff (http://example.com/info/), then use mod_rewrite to redirect requests for '/' or '/index.php' to '/info/index.php'. Would that work?
mod_rewrite怎么样?您可以为非SVN设置一个文件夹(http://example.com/info/),然后使用mod_rewrite将'/'或'/index.php'的请求重定向到'/info/index.php' 。那会有用吗?