title: Using mod_rewrite with mod_vhost_alias
body: <p>I was wondering if it's possible to use the vhost_alias module in conjunction with a rewrite rule. So in my VirtualHost I have this:</p>
  
  <pre><code>VirtualDocumentRoot /var/www/%2+/%1
  </code></pre>
  
  <p>For example, sub.mydomain.com will point to /var/www/mydomain.com/sub/<br>
  But I want to check if the folder exists to avoid getting a 404 error if I try to reach a bogus subdomain.</p>
  
  <p>So I tried to do this</p>
  
  <pre><code>RewriteCond /var/www/%2+/%1 !-d
  RewriteRule ^.*$ www.mydomain.com
  </code></pre>
  
  <p>But it doesn't work. Any ideas?</p>