0

I would like to redirect domain1.com to domain2.com using DNS. I would further like to redirect www.domain1.com to www.domain2.com.

For domain1.com zone file, do I need to have an A record or are CNAME records sufficient, e.g.

*                               IN      CNAME           domain2.com.
www.domain1.com                 IN      CNAME           www.domain2.com.

The goal is that when visitors visit domain1.com or www.domain1.com, they go to domain2

user788171
  • 279
  • 1
  • 5
  • 12
  • 4
    DNS doesn't have the ability to 'redirect'. What you have above says 'www.domain1.com is the same thing as www.domain2.com'. Maybe that's what you want, but that's not a redirect which is at the HTTP protocol. –  Feb 27 '15 at 21:22
  • OK, so it seems it is not possible?? – user788171 Feb 27 '15 at 21:27
  • @yoonix, that doesn't help answer the question. – user788171 Feb 27 '15 at 21:27
  • 1
    I edited a note in parenthesis into that comment: you may need to refresh your page. As for whether yoonix's comment helps answer the question...that doesn't matter. It's a comment. And a very applicable one, because you can't use DNS to perform a redirect. If you're not trying to accomplish a HTTP redirect, then please word your question differently. *Many* people think DNS handles website redirection. – Andrew B Feb 27 '15 at 21:30
  • You also [cannot use a CNAME at the root of a zone](http://serverfault.com/questions/613829/why-cant-a-cname-record-be-used-at-the-apex-of-a-domain), so that's yet another reason why you can't do this for `domain1.com`. – MadHatter Feb 28 '15 at 07:43

1 Answers1

3

Impossible.

You can redirect using your web server configuration, or with your preferred scripting language (such as PHP).

With DNS you can only point to the server, like you did in your example, but the domain name won't change from one to the other.

Daniel
  • 6,780
  • 5
  • 31
  • 60