1

I am having trouble figuring out my DNS record types. I want the www subdomain to be my "canonical" page, so my configuration looks like this:

www    A record type    actual ip address
@      301 redirect     www address

Is this correct? Do I need to replace the 301 redirect with a CNAME record type? From what I understand, CNAME is supposed to be used for www and @ is supposed to be the canonical, but I want it the other way around.

I am also concerned about SEO, but I am not sure how having a CNAME record instead of a 301 redirect affects this.

An additional issue I am having with this setup is that I can't use login@example.com for SSH and I need to use login@www.example.com. But this is just a minor nuisance.

masegaloeh
  • 17,978
  • 9
  • 56
  • 104
Mihai Oprea
  • 13
  • 1
  • 3

2 Answers2

2

A CNAME is not a redirect. It is just a canonical (or copy) of an A record. Set your A record for @ to the IP and the www as a CNAME to example.com. Then, in the web server configuration you can configure the root domain to redirect to the www subdomain. This way example.com and www.example.com point to the same place but users will only see www.example.com in their web browser.

Aaron J Spetner
  • 269
  • 2
  • 8
  • What is the difference between doing a server-level redirect vs a DNS level 301 redirect? – Mihai Oprea May 11 '14 at 15:23
  • 3
    There is no such thing as a DNS level 301 redirect. 301 is an HTTP status code that is returned by a web server. Some registrars (such as GoDaddy) offer a redirect option, but that is also a redirect. When using your registrar's redirect option for a domain, a DNS record is created that points to your registrar's server which then redirects to the site that you specify. – Aaron J Spetner May 11 '14 at 18:18
2

You can't CNAME @ without the world ending. Seriously, don't do that.

The best compromise is to either have both of them be an A record, or to CNAME www to @. If you manage the webserver on that IP, configure it to serve up a redirect if the Host header is for the base domain.

Andrew B
  • 31,858
  • 12
  • 90
  • 128