2

The article http://lifehacker.com/146448/geek-to-live--ban-time+wasting-web-sites recommends editing the Windows HOSTS file in c:\windows\system32\drivers\etc as a way to block certain websites.

I noticed some interesting behavior when adding the line: 127.0.0.1 google.com.

In Firefox 7.0, when I attempt to navigate to 'google.com', I get a Server Not Found error, as expected. However, when I attempt to navigate to 'www.google.com', the page is retrieved without error.

Why the different behavior? Why does it resolve the URL differently when the www is prepended to the domain name?

Update: With the line edited to '127.0.0.1 google.com www.google.com', both above requests are blocked. I'd still like to understand the reason for the different resolution. I see, using PING, that the URLs in question do resolve to different IPs.

4
  • If you had said IE, I have seen before that Google would "resolve" and connect , before I had my connection working properly in W7. We had seen this behaviour years before where MSN would work with my poor setup net , until i got dns and full connect working. I had always believed that somewhere in the OS , there were IP Numbers that resolved MSN just so a dns type problem would not exist for them. (and this time google) even though no DNS had come though YET for that computer (could be leftover junk from MSes DVD Image they sell me). Mabey Clear the DNS before testing ?
    – Psycogeek
    Sep 30, 2011 at 6:22
  • Note that this is a very poor way to achieve the desired goal. It mucks up everything else's name→address lookups, isn't scalable and maintainable for the large numbers of hostnames that one inevitably ends up with, and has too coarse a granularity in many cases. The far better ways to achieve this same end are (a) a Proxy Auto-Configuration file, or (b) a rewriting proxy HTTP server.
    – JdeBP
    Oct 6, 2011 at 13:27
  • Thanks JdeBP. Can you give a little more detail on how it can "muck up everything else's lookups"? Oct 7, 2011 at 18:21
  • I have.
    – JdeBP
    Nov 26, 2011 at 19:37

1 Answer 1

4

The www portion of an URL has some history behind it. Extracted from Wikipedia,

Many domain names used for the World Wide Web begin with www because of the long-standing practice of naming Internet hosts (servers) according to the services they provide. The hostname for a web server is often www, in the same way that it may be ftp for an FTP server, and news or nntp for a USENET news server. These host names appear as Domain Name System (DNS) subdomain names, as in www.example.com. The use of 'www' as a subdomain name is not required by any technical or policy standard; indeed, the first ever web server was called nxoc01.cern.ch,[27] and many web sites exist without it. Many established websites still use 'www', or they invent other subdomain names such as 'www2', 'secure', etc. Many such web servers are set up such that both the domain root (e.g., example.com) and the www subdomain (e.g., www.example.com) refer to the same site; others require one form or the other, or they may map to different web sites.

That being said, the inclusion of the www subdomain is customary most of the time, and www.google.com and google.com are two entirely different URLs, even if they point to the same IP address after a DNS resolution.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .