Webmaster Blog

Webmaster Resources

Rewriting “www” to “non-ww” Domain

Due to SEO aspects many webmasters rewrite all their “www” queries to “non-www” queries. Why that ? Simply because search engines might think there is duplicate content if they can access www.yourdomain.com and http://yourdomain.com at the same time.

That’s why you should rewrite www to non-www or vice versa permanently.

Here is the simple solution for that:

RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^yourdomain\.com
RewriteRule (.*) http://yourdomain.com/$1 [R=301,L]

Personally I think the shorter the better, but it’s different for each target group. Older people sometimes think that you have to type www in front of any domain name. This is completely up to you! Enjoy rewriting :)