I have a hosted rails application that gives every account a sub domain eg company.hosted_site.com

I have pointed our customers own domain to their subdomain via a A record and a cname so it looks like their own site.

But now i have 2 versions of the same site running so i need to now redirect the subdomain to the customers own domain.

My question is what redirect is best for this for SEO ?

thank you Rick

3 Answers 3


There are a couple of things you can use. First, assuming you have signed the domain up for Google Webmaster tools, you can select the prefered version of the URL. http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html

I would also add an HTACCESS rule to redirect visitors to the preferred URL.

RewriteCond %{HTTP_HOST} company.hosted_site.com [NC] 
RewriteRule ^(.*)$ http://www.hosted_site.com/$1 [L,R=301] 
  • +1 Using .htaccess is usually a bit better for the server, because it goes through Apache without having to process any of the RoR code.
    – Dan Blows
    Apr 30, 2011 at 12:37

as long as you get 301 site moved permanently, you'll be fine, doesn't matter which method you use to redirect, you just need to make sure to set the code properly.

  • It's correct to use 301, but I think it does matter which method you use. HTML or JavaScript redirects can be disabled on the client side. Using Apache, either by .htaccess or in the httpd.conf usually gives the best results.
    – Dan Blows
    Apr 30, 2011 at 12:40

If a file/domain has has moved for good you should use a "301 Moved Permanently"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.