StijnH
05-25-2009, 03:05 AM
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
Above code should remove 'www.' from all domains and subdomains. It is listed in the mod_rewrite FAQ and various other resources.
However, it does not work as expected with DirectAdmin. While trying to find a solution, I've read that you have a 'special' way of handling subdomains, which probably causes this problem.
I cannot add more domains to my hosting package, so the alternative way of adding subdomains is not possible.
http://domain.tld/ stays http://domain.tld/
http://www.domain.tld/ goes to http://domain.tld/
http://sub.domain.tld/ stays http://sub.domain.tld/
WRONG:
http://www.sub.domain.tld/ goes to http://sub.domain.tld/sub/
THIS SHOULD HAPPEN:
http://www.sub.domain.tld/ goes http://sub.domain.tld/
Any help will be appreciated!
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
Above code should remove 'www.' from all domains and subdomains. It is listed in the mod_rewrite FAQ and various other resources.
However, it does not work as expected with DirectAdmin. While trying to find a solution, I've read that you have a 'special' way of handling subdomains, which probably causes this problem.
I cannot add more domains to my hosting package, so the alternative way of adding subdomains is not possible.
http://domain.tld/ stays http://domain.tld/
http://www.domain.tld/ goes to http://domain.tld/
http://sub.domain.tld/ stays http://sub.domain.tld/
WRONG:
http://www.sub.domain.tld/ goes to http://sub.domain.tld/sub/
THIS SHOULD HAPPEN:
http://www.sub.domain.tld/ goes http://sub.domain.tld/
Any help will be appreciated!