Rewriting subdomain.domain.com when other 'subdomains' exist
Solution 1:
Add:
ServerAlias *.example.com
to the vhost and employ these rewrite rules:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^(www)\. [NC]
RewriteCond %{HTTP_HOST} ^(.*)\.example\.com [NC]
RewriteRule (.*) http://www.example.com/%1 [R=301,L]
If you already have a subdomain, eg. subsub.example.com
, explicitly set as ServerName/ServerAlias for another vhost, it will take precedence over the wildxard vhosts