Hey, simple problem again.. I can only find examples with domain.com hardcoded like this: rewritecond %{http_host} ^domain.com [nc] rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc] Code (markup): Does anyone know how to make the rule to generally apply for other .tld's or domains too? Just adding the www`? Thanks
You can try this (untested): RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301, L] Code (markup):
Here's one I use for my website, if that helps. RewriteCond %{HTTP_HOST} ^followtwitter\.net$ [NC] RewriteRule ^(.*)$ http://www.followtwitter.net/$1 [R=301,L]
I've found it! Allright, thanks for help guys.. now i just found this code that also works for subdomains. Source: ht*p://www.remichael.de/tmp/lang/en/seo/redirect-domain-to-www-but-exclude-subdomains/ RewriteCond %{HTTP_HOST} ^[^.]*\.[^.]*$ RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] RewriteCond %{HTTP_HOST} ^www\.(.*\.[^.]*\.[^.]*)$ [NC] RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L] Code (markup):