Have been trying to work this out for myself using mod_rewrite in a .htaccess file, but just can't seem to do it.
Basically if someone was to goto the URL...
...and "subdomain" does not exist, then send them to the "domain.com". Problem is that "subdomain" is unknown, as they are created on the fly, so I need a way to test that the folder exists, if it doesn't redirect, though if it does, display that website for that subdomain.
Hope I was clear.