<VirtualHost *:80>
        DocumentRoot /home/checkout/trunk
        ServerName dev.example.org
        ServerAlias *.dev.example.org

        LogLevel warn
        ErrorLog /var/log/apache2/error.log
        CustomLog /var/log/apache2/access.log combined
        ServerSignature On

        RewriteEngine On

        # If the request contains a subdomain and the directory exists, redirect
        RewriteCond %{HTTP_HOST} ^([^\.]+)\.dev\.example\.org
        RewriteCond /home/checkout/%1 -d
        RewriteRule ^(.*) /home/checkout/%1/$1 [L]

        # Redirect non-existing subdomains to the error page
        RewriteCond %{HTTP_HOST} ^([^\.]+)\.dev\.example\.org
        RewriteRule ^(.*) /home/checkout/error.html [L]

        # Hide .svn directories in checkouts
        <Directory ~ "/\.svn/">
                order allow,deny
                deny from all
        </Directory>

</VirtualHost>

