Ok, this is an old question, but since I found it on google, others might end up here as well and why not give those future visitors a different solution to the problem? (although it is technically not a answer to the OPs question since you asked for a redirect, but I think it does solve your problem)
Depending on what you want you can either:
1) Have everything for the domain go to the same directory: example.com www.example.com foo.example.com all go to /var/www/example.com/app/www
<VirtualHost *:80>
ServerName catch.all
ServerAlias *
VirtualDocumentRoot /var/www/%-2.0.%-1.0/app/www
</VirtualHost>
2) Have a directory structure like /var/www/[domain]/[subdomain]
Both example.com and www.example.com go to /var/www/example.com/www and shop.example.com will be served from /var/www/example.com/shop
<VirtualHost *:80>
ServerName sub.domain
ServerAlias *.*.*
VirtualDocumentRoot /var/www/%-2.0.%-1.0/%-3
</VirtualHost>
<VirtualHost *:80>
ServerName bare.domain
ServerAlias *.*
VirtualDocumentRoot /var/www/%-2.0.%-1.0/www
</VirtualHost>
Note: the www will be served by the sub.domain rule. And non-existing subdomains will result in a 404.