I use .htaccess to add "www." to the front of the domain name if it is not present, via:

Code:
# Add a leading www to domain if one is missing.
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
How could I go about changing the rule so that it does not add the www. when a subdomain is being accessed, e.g. sub.domain.com