I am starting a music blog at www.domain1.com. That URL is an alias shared with www.domain2.com which is just a domain I happen to have hosting with but is unused. In the future I may want to develop a site at www.domain2.com as a portfolio site but for now I have www.domain1.com that I want to use with my hosting.

At first I had www.domain1.com forwarding to www.domain2.com/domain1 and masking that URL so visitors would only ever see www.domain1.com but the URL never changed when people navigated and not having unique URLs is bad for many reasons. I also tried that because it would allow me to be able to develop sites at both domain2.com and /domain1. However, the unique URL thing is an issue. So I ditched that idea and I created an alias. Great! Now I have unique URLs. However now the same content displays at both domain2.com and www.domain1.com. Not great.

My question is how do I tell Google that for the content that is at domain1.com to index that site and don't credit www.domain2.com so I avoid duplicate content issues?

Do I add this to the config file?

RewriteEngine on
RewriteRule ^(.*)$ domain1.com$1 [NC,L,R=301]
  • You tagged this with canonical-url, which indicates you're aware of what that's for. That would certainly apply here, is there a reason you don't want to simply use that?
    – dan
    Commented Jul 31, 2016 at 6:04
  • I definitely want to. I have always used it at the specific link level. How do I apply it at the highest level of www.domain1.com so that any and all links for the entire domain give preference to www.domain2.com? Thank you for editing my post. I completely forgot that URLs needed to be referenced a certain way. I've only posted here a few times and want to make sure I stick to the rules and will make sure to remind myself to check my posts to ensure I follow the guidelines before I hit the post button.
    – codemonkey
    Commented Jul 31, 2016 at 6:05
  • OK about the edit, it's best to reply to comments as just a comment, and not edit the question to answer them. Just to clarify, you have two sites, but want only one to receive "credit" so as not to avoid duplicate content? Most webmasters would just add noindex meta or server header to indicate one of the sites shouldn't be indexed, or 301 redirect one domain to the other, which accomplishes the same. Is that what you're asking how to do?
    – dan
    Commented Jul 31, 2016 at 6:16
  • I believe so. domain2.com is an alias so domain1.com has the same content. I domain2.com to get all the credit. I am essentially sharing a basic hosting account with 2 domains and ideally I would want to be able to develop a site on domain1.com as a portfolio site but it seems like I would need to upgrade my hosting package up from basic to truly share hosting across two urls. For now, since I have no plans for using domain 1 can I make the redirect a 302? And that would ensure that the domain 2 gets all the credit and avoids duplicate content?
    – codemonkey
    Commented Jul 31, 2016 at 6:34
  • A 302 is just a temporary redirect for clients and search engines alike. You'll need to use a 301, noindex, or canonical URLs to indicate to Google which is the preferred URL to index. You likely wouldn't get penalized if you don't, but you won't have any control over search engine results, so you'll need to use one of the above if that's important to you. There are a lot of questions here on how to apply them, just use the Search function above to find them.
    – dan
    Commented Jul 31, 2016 at 7:41

2 Answers 2


In the future I may want to develop a site at www.domain2.com

This is the concern with regards to a 301 redirect. A 301 redirect is considered permanent. Browsers and everything in between will cache the 301, so that if you did want to develop a site on domain2 later it could be problematic.

There's no point have the site accessible on both domain1 and domain2.

If you just want to forget about domain2 for the time being (strictly the main domain on the account) then you could conditionally serve a 403 Forbidden when accessing via domain2.com.

For example, using mod_rewrite in .htaccess in the document root:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.com [NC]
RewriteRule ^ - [F]

By using the F flag, a 403 Forbidden will be served when accessing via domain2.com.

To instead serve a 404 Not Found, you could change the RewriteRule to read:

RewriteRule ^ - [R=404,L]

the only fully seo compliant way is to let google index domain2 and get rid of domain1 out of the schema.

canonical is just a recommendation, to 301 the whole domain isn't a good way too. sure both ways work. but if talking bout seo - they aren't optimal solutions

  • 1
    From Google, 301 redirects are particularly useful in the following circumstances: You've moved your site to a new domain, and you want to make the transition as seamless as possible. This is the de facto method for moving domains, as indicated in countless answers on this site, and companies typically have multiple domains redirected to their main domain via a 301 redirect. Can you point to any authoritative source to back this up: 301 the whole domain isn't a good way too...they aren't optimal solutions ?
    – dan
    Commented Jul 31, 2016 at 22:06
  • IF Google endorses 301 and canonical it's good enough for me. I think Evgenly is just saying that if one is having any issues ensuring every url is redirecting and to ensure as little duplicate content as possible then just use a clean URL/server. However, what's done is done here. There's no looking back.
    – codemonkey
    Commented Aug 1, 2016 at 1:06
  • @dan you just can measure a site performance of two sites: first giving 200, and second giving 301, to get to know, that, 200 is faster, ergo, better. site performance is one of a high level ranking factors for google. is it autoritative enough?
    – Evgeniy
    Commented Aug 1, 2016 at 5:28
  • @Evgeniy I think you're conflating things: The OP is asking, how do I tell Google that for the content that is at domain1.com to index that site and don't credit www.domain2.com . Just stating, get rid of domain1 out of the schema does not resolve that, nor does it provide any SEO benefit such as passing link juice that a 301 redirect would. We prefer answers here that are supported by authoritative sources, such as the links I provided in my comments. Unsupported statements do not qualify as such.
    – dan
    Commented Aug 1, 2016 at 6:41

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.