I want to block a path (eg https://superuser.com/megasupersecret), but not the whole domain (http://superuser.com). In the host file, i've tested like this:

127.0.0.1  https://superuser.com/megasupersecret
127.0.0.1  superuser.com/megasupersecret

But it doesn't work. It doesn't block anything. What can I do?

  • 3
    There's no such thing as a "postdomain" and the hosts file is for handling domain to IP address mappings, not parts of a URL. – Der Hochstapler Jun 5 '14 at 13:13

This will not work unfortunately. Hosts files are used to resolve IPs to domain and host names... not full URLs. The reason is that it is designed to resolve the names and IPs of hosts on a network (eg yourmachine.yourdomain.local or similar) - and is often confuised with web URLs.

It may also be worth noting that by editing your hosts file, you only mess up someones ability to resolve www.google.com to 173.194.41.146 (according to my ping anyway). If your user used a web-ping to find the ip and then went to http://173.194.41.146, they would still get through to Google!

there is no effective way to do this within windows natively, so you need to start looking into installing some sort of web-proxy on your PC (or a dedicated server) if doing this corporately.

  • I would add that a proxy/firewall would be the best way to block a domain, as adding entries to the host only affects domain name resolving. – SlightlyCuban Jun 5 '14 at 13:56
  • @SlightlyCuban - fantastic point. Answer updated to reflect this! – Fazer87 Jun 5 '14 at 13:57
  • If looking for an example proxy that can be used just for this purpose, I would propose Privoxy. – HalosGhost Jun 5 '14 at 16:11

Path blocking

This covers firefox, following the link below for exact details on URL matching.
Get the gpoedit.msc templates here.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.