-
Subdomains in .htaccess
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
-
I always do the opposite.
Code:
RewriteCond %{HTTP_HOST} ^yourdomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L]
And that will only add to http://yourdomain.com/