Forum Moderators: phranque
www.mydomain.com and
mydomain.com
I stopped getting google traffic this weekend and I'm afraid I'm dealing with a duplicate content penalty.
What's the correct way to handle mydomain.com to make google happier? I tried a 301 redirect in .htaccess but ended up creating an infinite loop.
Google has pageranked my site
Google doesn't give PageRank for sites, only for pages - hence the difference here:-
Google has pageranked my site separately for
www.mydomain.com and mydomain.com
That is perfectly correct, as they are two separate/distinct pages.
OK, enough Google. See here : [webmasterworld.com...] for more on PR.
The 301 is the correct thing to do. The infinite loop is probably because you are forwarding all pages from example.com to www.example.com. And www is actually just a subdomain of example.com, so the redirect will always be redirecting (assuming both sites to be hosted on the same server/IP address).
I suspect you've done something like:-
redirect permanent / www .example.com
What you need is:-
RewriteEngine on
RewriteCond %{HTTP_HOST}!^www\.domain\.com [NC]
RewriteRule ^(.*) http://www.domain.com/$1 [L,R=301] TJ
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule (.*) [domain.com...] [R=301,L]
I wanted the [www...] version to appear in the browser not the http://