Using the hosts file to stop people from reading some websites

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

What would be the proper syntax for this to work?

I even tried
to test re-directing to

Do I need to restart my computer for this to work?

I believe the host name has to match exactly, so you might try 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, and all the other s.

Saving the HOSTS file triggers a DNS cache flush, so the “ipconfig /flushdns” step is not necessary. Can’t hurt though.