This question already has an answer here:

I'm trying to map somedomain.com to here.anotherdomain.com. I can do any sub domains of the original using a CNAME but the root domain ( somedomain.com ) needs an A record. This is currently set to the ip address of the server ( anotherdomain.com ).

My question is, do I add a CNAME record of somedomain.com to point to here.anotherdomain.com on the server DNS zones?

NAMESERVER RECORDS
A somedomain.com 123.123.123.123
CNAME www here.anotherdomain.com

SERVER RECORDS
CNAME somedomain.com here.anotherdomain.com

The nameservers are at codeigniter and the server is cPanel.

Thanks for any help

Joe

marked as duplicate by Andrew B, kasperd, Ward, Andrew Schulman, mailq Oct 8 '14 at 8:08

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

The DNS spec, RFC 1035, does not for the 'naked domain' (domain.com) to have CNAME's. More technically, it states that a CNAME must be alone, so you can't have both CNAME's and NS's (and other records required for a domain to work).

Cloudflare went ahead and tried to handle this on their end, by allowing a CNAME as the root record, whereafter they will resolve it and present an A record to the end-user. You can use Cloudflare for their DNS service only, if you so wish - so that's always an option.

Source: http://blog.cloudflare.com/introducing-cname-flattening-rfc-compliant-cnames-at-a-domains-root/

Just put both somedomain.com and here.anotherdomain.com to the same ip address, create a vhost for here.anotherdomain.com and no vhost for your somedomain.com
or
put both in the same vhost enter somedomain.com and here.somedomain.com then make a rewright to your apache to your default domain here.anotherdomain.com.

  • I think this is what I'm looking for. So am I write in thinking with the CNAMES in place, doing it this way will mask the domain? – jhodgson4 Oct 7 '14 at 15:41
  • @jhodgson4 No, you can't do it with a CNAME because it is a violation of standards. The best you can do (barring implementation specific behavior such as Cloudflare's) is to point the apex at a webserver that redirects them to the proper site. – Andrew B Oct 7 '14 at 18:29

I'm puzzled, because somedomain.com doesn't need a A record. See for example the records for fdn.fr and www.fdn.fr. If your DNS provder require a A record for somedomain.com, you should put a HTTP redirect or something like that behind.

Yes you should add a CNAME record. If you really want users to connect to here.anotherdomain.com you should consider redirection mechanism at higher protocol level (e.g. HTTP 301 redirect)

  • 1
    You cannot CNAME the apex of a domain if the implementation is standards compliant. (ignoring Cloudflare, because what they do isn't a real CNAME) – Andrew B Oct 7 '14 at 18:27

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