2

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?

1
  • 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. Jun 5, 2014 at 13:13

2 Answers 2

7

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.

4
  • 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. Jun 5, 2014 at 13:56
  • @SlightlyCuban - fantastic point. Answer updated to reflect this!
    – Fazer87
    Jun 5, 2014 at 13:57
  • 1
    If looking for an example proxy that can be used just for this purpose, I would propose Privoxy.
    – HalosGhost
    Jun 5, 2014 at 16:11
  • Privoxy is not able to block HTTPS paths, only the domain can be blocked.
    – Shayan
    Oct 18, 2019 at 12:46
0

Path blocking

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

1

You must log in to answer this question.

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