title: Dynamic subversion repos via subdomains (in Apache)
body: <p>I'm trying to set up a subdomain-to-repository translation in Apache. Example:</p>
  
  <pre><code>foobars.domain.com -&gt; /server/svnrepos/foobars
  </code></pre>
  
  <p>I've tried to get this done with <strong>mod_rewrite</strong>:</p>
  
  <pre><code>RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
  RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.domain\.com$ [NC]
  RewriteRule ^/svn(.*) /svn/%2$1 [PT]
  </code></pre>
  
  <p>However, this causes problems with basic svn operations; 'checkout' causes this pretty thing:</p>
  
  <pre><code>$ svn co http://foobars.domain.com/svn
  svn: '/svn/foobars/!svn/vcc/default' path not found
  </code></pre>
  
  <p>I don't have any limitations in terms of server setup (my machines, os, etc). Is there any way to get this translation handled by Apache? I've looked at mass virtual hosts, but I don't see a way to extend the concept to DAV locations (I wish there was a VirtualSvnPath...). The way mod_dav_svn forces you to either 1) explicitly define your svn repo path, or 2) define the parent, is very limited. </p>
  
  <p>Perhaps the 'SVNSpecialURI' can be of some use, although I can't find any documentation on it...</p>
  
  <p>Assuming that my ultimate goal is to map a <strong>subdomain</strong> to an SVNPath, what are my options?</p>
  
  <p>My current conf as a reference:</p>
  
  <pre><code>&lt;VirtualHost *:80 *:443&gt;
      ServerAdmin admin@domain.com
      DocumentRoot "/server/www"
      ServerName domain.com
      ServerAlias *.domain.com www.domain.com domain.com
      ErrorLog logs/domain-error_log
      CustomLog logs/domain-access_log common
  
      DirectorySlash Off
  
      RewriteLogLevel 9
      RewriteLog /server/log/apache-rewrite.log
  
      RewriteEngine On
      RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
      RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.domain\.com$ [NC]
      RewriteRule ^/svn$ /svn/ [QSA]
  
      RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
      RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.domain\.com$ [NC]
      RewriteRule ^/svn(.*) /svn/%2$1 [PT]
  
  &lt;Location /svn&gt;
      DAV svn
      SVNParentPath /server/svn
  &lt;/Location&gt;
  </code></pre>
  
  <p></p>