10

I'm a developer and I'm having trouble setting up some hosting, and I hope you guys can help me out.

I've got a domain I'm setting up for a friend. URLs work fine when I use the short form, like http://example.com. That is, the pages render properly and I get HTTP/200 responses. When I try http://www.example.com, however, I get a HTTP/502 error. Pinging it gives me,

Ping request could not find host www.example.com. Please check the name and try again.


I'm stumped, because I don't know enough terminology to formulate a good keyword search. Can anyone give me some info on what I might need to do to set up some kind of alias so that the standard www. form will work? I don't know whether to talk to my registrar or my hosting company, what to ask them for, or where to look in the various control panels.

Any help at all — even just naming the different pieces — would be helpful. I don't know my TLDs from my domain aliases from my CNAMEs.

TRiG
  • 1,167
  • 2
  • 13
  • 30
Steve Cooper
  • 205
  • 3
  • 6

4 Answers4

8

It would seem that you don't (or your friend) doesn't have a DNS record for 'www' in his domain, this would account for the problem of not being able to resolve the address.

To resolve this it should be as easy as creating a new A record (also known as a HOST record) for 'www' and mapping it to the IP address of his web server, with his DNS provider.

A list of DNS record types can be found at http://en.wikipedia.org/wiki/List_of_DNS_record_types

commandbreak
  • 969
  • 4
  • 6
  • 1
    Steve would be better off using a cname since it appears as though he would like both urls above to resolve to the same location. – Patrick R Feb 09 '10 at 01:36
  • No, the CNAME is a terrible idea since it would alias every type, not just the A, so he will get also the SOA record, the NS, etc. – bortzmeyer Feb 10 '10 at 12:28
  • @bortzmeyer - you posted this exact comment twice. sounds like you feel pretty strongly about this. You're not wrong *but* in this situation you're also not correct since that has no bearing on what this person is attempting to do. – Patrick R Feb 11 '10 at 20:12
  • 1
    I think what bortzmeyer is saying is if you create a 'www' cname to domainname.com not only will you pull back the A record, you will multiple record types (NS, SOA, A and maybe MX). Creating a seperate A record for 'www' and using the same IP address would be a better solution. – commandbreak Feb 12 '10 at 02:25
6

There's really no difference in these two names other than the fact that one has a subdomain prepended to it and the other doesn't. You can set up resource records to take advantage of an almost unlimited amount of subdomains once you own a domain name.

There are at least 30 different types of resource records. For now you can probably get by with focusing on two:

  • aname ("a" record - primary address record)
  • cname (Alias of one name to another)

www is by far the most common subdomain but there are many others. Take a look at the following examples:

  • gmail.google.com
  • my.yahoo.com

What you need to understand is that google.com and yahoo.com are domain names. Anything before that is referred to as a host name or a subdomain. As long as you take the necessary steps to set up your DNS resolution to resolve these subdomains to either their own IP address (use A Name) or as an alias (use a Cname) and you set up your webserver to understand such requests you'll be set.

In your case you should use a cname to point www.domainname.com to domainname.com. A cname is more appropriate as an answer only if you intend to point both to the same IP. That way if you need to change your IP in the future, you'll only need to adjust one record.

As for getting your webserver to understand both requests there are lots of examples for both Apache and IIS on serverfault. Do a search and you'll find everything you need. Look for virtual hosts.

Edit: Here's a cross reference about cnames. They have their place too. Use the tool that best suites your circumstances.

Patrick R
  • 2,925
  • 1
  • 18
  • 27
  • Patrick R is spot on with his answer. Also you want to keep in mind that every record has a TTL (Time To Live), so by using CName references you can guarantee that if you ever change your servers location via IP Address that all of your CNames will change at once. If you had to update multiple AName records you may have some confusing results when they are switching at different times. – Shane Feb 09 '10 at 14:00
  • No, the CNAME is a terrible idea since it would alias every type, not just the A, so he will get also the SOA record, the NS, etc. – bortzmeyer Feb 10 '10 at 12:29
  • 1
    @bortzmeyer - how would this idea be *terrible* for Steve's situation above? where does he imply that he needs to avoid the SOA record, the NS, and the items you mysteriously refer to as *etc*? – Patrick R Feb 11 '10 at 12:47
  • Nothing mysterious in etc: the CNAME would get *all* the records of domainname.com in www.domainname.com. The first breakage would probably come from the NS records because www.domainname.com would then look like a delegation. – bortzmeyer Feb 12 '10 at 11:07
  • And that's exactly why I said he would be better off with a cname in this situation. – Patrick R Feb 12 '10 at 12:56
3

What’s the difference between domainname.com and www.domainname.com?

A host record ( also known as an A record ).

You could also use an alias (what's known as a CNAME) although this would require the client to do two DNS lookups, so your better off with an A record.

Nick Kavadias
  • 10,758
  • 7
  • 36
  • 47
  • @nick - what would take more resources, a client's dns query making a request of a cname or an admin who needed to update a single IP address multiple times because multiple hosts (aliases) pointed to that single address via anames? – Patrick R Feb 09 '10 at 02:19
  • if your running a big site, then the extra few minutes is worth the reduction in dns query overhead. – Nick Kavadias Feb 09 '10 at 02:34
  • I run several large sites and never noticed that cnames were a significant overhead. I'll take a closer look. What would be a good use for cname records? Should I consider using them in a different way? – Patrick R Feb 09 '10 at 02:51
  • personal preference maybe? I never use them for public sites. If 90% of your traffic is hitting a www. addresses, then you want that to be an a-record not a cname. – Nick Kavadias Feb 09 '10 at 02:56
  • personal preference? That I'll go with but you did mention query overhead. Is that not then the case? – Patrick R Feb 09 '10 at 03:51
  • there is definitely additional query overhead. try it & see – Nick Kavadias Feb 09 '10 at 04:30
  • @nick - where should look for this additional overhead? how much overhead are you talking about? from an administrative perspective why not let the machines do the work? I'd rather kick back and drink a cup of coffee. – Patrick R Feb 09 '10 at 12:58
  • IMHO, it's all a matter of personal preference. I see valid points to both arguments. – joeqwerty Feb 09 '10 at 13:27
1

Technically example.com and www.example.com are different domain names. One could have 2 completly different websites on them (although that's quite bad practice).

What you need to do is set up a new record for www to point to the same host (ie computer/server/machine/whatever) as example.com.

Amandasaurus
  • 30,211
  • 62
  • 184
  • 246