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:
VirtualDocumentRoot /var/www/%2+/%1
For example, sub.mydomain.com will point to /var/www/mydomain.com/sub/
But I want to check if the folder exists to avoid getting a 404 error if I try to reach a bogus subdomain.
So I tried to do this
RewriteCond /var/www/%2+/%1 !-d
RewriteRule ^.*$ www.mydomain.com
But it doesn't work. Any ideas?