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.
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
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:
www is by far the most common subdomain but there are many others. Take a look at the following examples:
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.
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.
Technically
example.com
andwww.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) asexample.com
.