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.
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 – 2011-09-30T06:22:12.387
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 – 2011-10-06T13:27:24.693Thanks JdeBP. Can you give a little more detail on how it can "muck up everything else's lookups"? – slachterman – 2011-10-07T18:21:35.733
I have. – JdeBP – 2011-11-26T19:37:53.683