Multiple domains for one site: alias or redirect?

29,863

Solution 1

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. Please read this article CAREFULLY as it distinguishes between duplicate content on the same site (as in "www.example.com/skates.asp?color=black&brand=riedell and www.example.com/skates.asp?brand=riedell&color=black") and specifically says "Don't create multiple pages, subdomains, or domains with substantially duplicate content."

Solution 2

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.

Solution 3

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.

Solution 4

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.

Share:
29,863
playjava
Author by

playjava

Updated on May 06, 2020

Comments

  • playjava
    playjava about 4 years

    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". Note, however, this only applies to content ON THE SAME SITE, exemplified in the article with "www.example.com/skates.asp?color=black&brand=riedell or www.example.com/skates.asp?brand=riedell&color=black". In fact, the article explicitly says "Don't create multiple pages, subdomains, or domains with substantially duplicate content."

  • playjava
    playjava almost 16 years
    That's what I'm wondering, if it's just superstition left over from days gone past.
  • playjava
    playjava almost 16 years
    Thanks for the rewrite and the excellent Google link! Funny how googling earlier returned paranoid SEOers and not the official docs!
  • Bart van Heukelom
    Bart van Heukelom about 15 years
    Actually, if Google detects they're the same page, it will combine the pagerank, so it doesn't matter.
  • Mark Ransom
    Mark Ransom about 15 years
    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.
  • MS6
    MS6 over 14 years
    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)
  • kliron
    kliron over 14 years
    A spider is an HTTP client like any other, so it too would be redirected to the canonical domain.
  • Frank Farmer
    Frank Farmer over 14 years
    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.
  • Tamik Soziev
    Tamik Soziev about 12 years
    i am having this problem with my SSL certificate. But when i added a Redirect permanent / mysite.com to http.conf - browser says i have a redirect loop error