8

Possible Duplicate:
www.example.com vs example.com

Is there any particular reason that "www." is required for some websites? It seems to me that all this does is cause inconvenience (at best) and confusion.

For example, http://math.cmu.edu gives a "Server not found" error, but http://www.math.cmu.edu takes you to the right place. Also, on HD Nation (Revision 3) they advertise for Netflix, but warn that you need to include "www." for the show-specific URL and discount to count.

Andrew Keeton
  • 183
  • 1
  • 5

4 Answers4

15

It depends on how DNS is setup. If they do not have an A (or host) record at math.cmu.edu pointed at the IP of the web server, then the site will be inaccessible without adding the "www" in front.

There is no standard that says a site needs to be accessible without the "www", but it has been a common practice for a long time since the web is so prevalent.

Doug Luxem
  • 9,592
  • 7
  • 49
  • 80
  • 1
    i would not reference "www" out of spite for a term that should have been abandoned long ago... – djangofan Aug 24 '09 at 21:53
  • 1
    Actually, it doesn't have to be an A record. CNAME will work just fine too. However, it could still not work, even with the DNS configured properly, if the web server is configured to serve for name-based virtual hosts and the name without "www" is not configured. – af. Aug 24 '09 at 22:45
7

There is a VERY good reason why WWW exists for domain names, and it is: cookies!

If you set a cookie on example.com then it is accessible from www.example.com, but also from admin.example.com and images.example.com. By accessing your website through www.example.com and setting cookies for www.example.com that means that your cookies are not going to be passed to admin.example.com.

Sometimes you want this. Sometimes you don't. You need to decide straight up if you need cookies accessed across subdomains on your site.

Case in point, we started running our website on www.example.com. When they needed to add SSL to the website, some smart cookie decided to put the SSL on secure.example.com. Now when users move from www.example.com to secure.example.com their cookie is lost and so is their login information.

That said, I can't see any good reason why you would have www.secure.example.com

Mark Henderson
  • 68,316
  • 31
  • 175
  • 255
  • the solution in your example above is to either do what sane people do and reconfigure the web server to allow both http and https on www.example.com, or to run the ssl on secure.www.example.com (with cookies on www.example.com shared with all subdomains of www.example.com) – cas Aug 24 '09 at 21:42
  • 2
    secure.www.example.com? Yuch, I can see the question now: "Why does this website use secure.www.example.com?" Anyway, who said anything about sanity? Hehe I've actually asked a few questions on here about how to separate ourselves from the guy who did this to us... – Mark Henderson Aug 24 '09 at 21:47
  • well, now you have two viable solutions. enjoy :) – cas Aug 24 '09 at 21:49
2

there is no reason. domain names are arbitrary (although there are some well-known conventions like www. for webservers, ftp. for ftp servers, mail. or smtp. or mx. for mail servers etc).

www.example.com and example.com may refer to the same machine (via A records or CNAME) or they may point to completely different machines.

in the latter case, the only way to have http://example.com/ and http://www.example.com/ get to the same site is to have a httpd running on example.com that issues a redirect to www.example.com

(it's not unusual for this redirection to occur even when two or more domains point to the same site & machine - e.g. apache's "UseCanonicalName on" and mod_rewrite to redirect requests for the non-canonical name to the canonical name for the site)

cas
  • 6,653
  • 31
  • 34
  • There is a common misconception that www is the standard for a website. In reality it is just a commonly adopted convention. In this particular case, quite clearly the DNS isn't pointing the base domain (math.cmu.edu) to a server running a web service, which is why you get the error message, whereas www.math.cmu.edu is pointing to a running web server. I am amazed at how often this gets overlooked by web masters. – wolfgangsz Aug 24 '09 at 23:38
  • It IS a "standard" (as in commonly adopted convention) - just not a technological standard such as those put out by ISO or IEEE. As a side note, browsers often attempt to add a "www." prefix if the page is not found, and a ".com" suffix... You're right though: it is a commonly adopted convention in truth. – Mei Aug 25 '09 at 00:56
0

Because that's how they set up their webserver.

Edited to add:

You don't need to do it this way for your own server. In fact, you can use whatever hostname you like. But www is pretty common and kind of a defacto standard among users.

Alternatively, they may have already used the @ record for the domain for something else, and can't change it for that reason.

Ernie
  • 5,324
  • 6
  • 30
  • 37