views:

2370

answers:

6

I'm setting up a number sites right now and many of them have multiple domains. The question is: do I alias the domain (with ServerAlias) or do I Redirect the request?

Obviously ServerAlias is better/easier from a readability or scripting perspective. I have heard however that Google likes it better if everything redirects to one domain. Is this true? If so, what redirect code should be used?

Common vhost examples will have:

ServerName example.net
ServerAlias www.example.net

Is this wrong and should the www also be a redirect in addition to example2.net and www.example2.net? Or is Google smart enough to that all these sites (or at least the www) are the same site?

UPDATE: Part of the reasoning for wanting aliases is that they are much faster. A redirect for a dialup user just because they did (or didn't) use the www adds significantly to initial page load.

UPDATE and ANSWER: Thanks Paul for finding the Google link which instructs us to "help your fellow webmasters by not perpetuating the myth of duplicate content penalties".

+8  A: 

Redirecting is better, then there is always one, canonical domain for your content. I hear Google penalises multiple domains hosting the same content, but I can't find a source for that at the moment (edit, here's one article, but from 2005, which is ancient history in Internet years!) (not correct, see edit below)

Here's some mod-rewrite rules to redirect to a canonical domain:

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

That checks that the host isn't the canonical domain (www.foobar.com) and checks that a domain has actually been specified, before deciding to redirect the request to the canonical domain.

Further Edit: Here's an article straight from the horses mouth - seems it's not as big an issue as you might think.

Paul Dixon
Thanks for the rewrite and the excellent Google link! Funny how googling earlier returned paranoid SEOers and not the official docs!
Jonah Braun
FWIW, I didn't find that link until I did a google search limiting the hits to pages modified in the last year.
Paul Dixon
Using this method, does it allow your redirected domain name to be indexed, or will only the redirect URL be indexed ? (so it becomes only an access URL)
Daan
A spider is an HTTP client like any other, so it too would be redirected to the canonical domain.
Paul Dixon
There are really two questions when it comes to duplicate content. (1) Are you penalized for having duplicate content? (2) Are there any disadvantages of duplicate content? Google has clearly stated that there is no penalty. However, there are still minor disadvantages -- google WILL index both pages, and hide one copy under the "duplicate results omitted" link. And google spends time crawling those duplicates that you'd really prefer it spent on your other content. Is duplicate content something to panic about? Probably not. Is it something to avoid when possible? Yes.
Frank Farmer
A: 

Nowadays I doubt it matters. If you see both entries in google, then you know you're doing it wrong.

Rich Bradshaw
That's what I'm wondering, if it's just superstition left over from days gone past.
Jonah Braun
A: 

If half the links to your site refer to one URL and half refer to another, each URL is only going to get half the pagerank. Even if Google doesn't penalize your rank for having duplicate content, you're going to suffer.

Mark Ransom
Actually, if Google detects they're the same page, it will combine the pagerank, so it doesn't matter.
Bart van Heukelom
Yeah, that occurred to me recently - Google aren't dummies, they probably have 100 different ways of knowing they're the same page. I think I had just read this somewhere before leaving this answer, and it sounded good at the time.
Mark Ransom
A: 

Server aliasing can cause problems with CGI session continuity: since cookies are attached to the domain they were served from, CGI scripts have to be carefully written so that they are aware of the aliasing, or all links within and into the site have to be relative, or both - it is much harder to avoid niggly little hard-to-debug problems due to the browser serving you different cookies based on whether the user last entered your site through name.tld or www.name.tld.

moonshadow
+1  A: 

If they are entirely different domain names, you will want to redirect because otherwise cookies can not be shared between the two. If a user logs into your website at example1.com, they will need to log in again if they visit example2.com.

If they are just different subdomains (example.com vs www.example.com) this won't matter.

Adam Hughes
+1  A: 

SSL certificates can also be an issue (wild card certs mitigate this but are more expensive).

So if the cert is only bound to www.example.com, it won't validate for example.com. If this circumstance applies to your case, then carefully handling, redirects and hyperlink references in your html and javascript is very important.

micahwittman