Say I want to block someone who is not computer-savvy from reading some websites.
Could I just use the hosts file, and add, say
Would this work?
Based on the other entries in my hosts file, it seems like this should work, but I tried it and it does not work. I can still go to yahoo.com
What would be the proper syntax for this to work?
I even tried
to test re-directing yahoo.com to cnn.com
Do I need to restart my computer for this to work?
I believe the host name has to match exactly, so you might try www.yahoo.com if that’s what you’re typing into your browser. I don’t think the hosts file on Windows allows wildcards either, although I stand to be corrected.
Oh, and it’s possible that you need to flush your DNS cache for it to work. I can’t remember in what order things get checked (i.e. if it’s hosts file, then cache, or cache then hosts file). Open a command prompt and type “ipconfig /flushdns” to clear the cache.
MrSquishy nails it in one.
The name must match exactly with no wildcarding. So that means you need separate entries for www.yahoo.com, mail.yahoo.com and all the other whatever.yahoo.com s.
Saving the HOSTS file triggers a DNS cache flush, so the “ipconfig /flushdns” step is not necessary. Can’t hurt though.