Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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://domainname.com

That is, the pages render properly and I get HTTP/200 responses. When I try

http://www.domainname.com

I get a HTTP/502 error. Pinging it gives me "Ping request could not find host www.domainname.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.

Thanks,

Steve.

share|improve this question
add comment

4 Answers 4

up vote 6 down vote accepted

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.

share|improve this answer
    
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 9 '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
    
@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
add comment

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

share|improve this answer
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 9 '10 at 1: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 2:25
add comment

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.

share|improve this answer
    
@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 9 '10 at 2:19
    
if your running a big site, then the extra few minutes is worth the reduction in dns query overhead. –  Nick Kavadias Feb 9 '10 at 2: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 9 '10 at 2: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 9 '10 at 2:56
    
personal preference? That I'll go with but you did mention query overhead. Is that not then the case? –  Patrick R Feb 9 '10 at 3:51
show 3 more comments

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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