-3

I have 2 records at amazon route53:

  1. A: value example.com, value - elastic IP address

  2. CNAME: value: www.example.com, value - example.com

Should I change the value of CNAME to be ec2-my-elastic IP address.us-west-1.compute.amazonaws.com? I also read I should add redirect with the code 301 somewhere at my web server, should I do that and how and why?

1 Answer 1

3

It is rather unclear what you're asking, but I'll give it a shot and answer it.

What is a CNAME?

A CNAME or Canonical Name record is a type of DNS record. It is used to when you want to point a domain or subdomain to the IP address of another domain. An example where this would be useful is if you use Google Apps. You would set a CNAME of mail.example.com to something like GHS.googlehost.com to forward the clients to Google. It also happens to let Google know which domain is being requested out of the countless ones using the Apps platform.

Should I use a CNAME or A Record for the WWW subdomain? Technically, the answer doesn't matter because if you set a CNAME to the A Record of your root of example.com it will work and users won't notice a thing if they type www.example.com or just the root of example.com. That being said it is often preferable to use an A record because a CNAME causes 2 DNS look-ups to occur. The first look-up will return that the record is actually the record for example.com. The second one obviously being getting the record for example.com. If you have just an A record it only requires one look-up. While DNS isn't too intensive setting an A record may increase the first load time of your site marginally as well as lower DNS traffic which may help if the site grows.

What should the records look like then? If you set an A record for the www subdomain it will look exactly like your root A record except the host will be www.

example.com. IN A 10.0.0.0
www IN A 10.0.0.0

If you decide to use a CNAME for whatever reason it would be pointing towards the root like so:

example.com. IN A 10.0.0.0
www.example.com. IN CNAME example.com
4
  • is it possible to setup a redirection from www.example.com to example.com? Right now both www.example.com and example.com are accessible.
    – Incerteza
    Mar 16, 2014 at 6:35
  • Assuming you are not using SSL you can configure a VirtualHost for www to do a 301(Permanent) redirect to the root(example.com).
    – Jacob
    Mar 16, 2014 at 7:19
  • where: at my domain registar or at ec2?
    – Incerteza
    Mar 16, 2014 at 7:51
  • @Alex That's a completely separate question to this one. It has nothing to do with DNS. And it's been answered many times all over the Internet including at this site. Mar 16, 2014 at 13:46

Not the answer you're looking for? Browse other questions tagged .