EDIT:
How can you redirect all non-active subdomains to 'www'?
Here I try to redirect all subdomains not listed to 'www'.. I can't make it work properly because %1 and %2 doesn't return anything.. Here I'm trying to redirect to google.com just to check the returned %2 value.., but it doesn't return anything and the redirect url is http://www.google.com/
RewriteCond %{HTTP_HOST} !^(admin|demo|www)\.([^\.]+\.[^\.]+)$ [NC]
RewriteRule ^(.*)$ http://www.google.com/%2 [L,R=301]
this is what I really want to do
RewriteCond %{HTTP_HOST} !^(admin|demo|www)\.([^\.]+\.[^\.]+)$ [NC]
RewriteRule ^(.*)$ http://www.%2/$1 [L,R=301]
Untested but it should work..
Presuming DNS entries already exist, you could use something I do on a couple domains:
This takes requests in the form of
sub.domain.com
and pushes it todomain.com/sub
.You could remove the
%1
and get the following which would not use the subdomain-to-path method I'm employing thusly: