Block specific url paths

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?

Smith Johansson

Posted 2014-06-05T13:00:27.000

Reputation: 29

3There'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 – 2014-06-05T13:13:55.863

Answers

5

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.

Fazer87

Posted 2014-06-05T13:00:27.000

Reputation: 11 177

Privoxy is not able to block HTTPS paths, only the domain can be blocked. – Shayan – 2019-10-18T12:46:08.323

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 – 2014-06-05T13:56:44.253

@SlightlyCuban - fantastic point. Answer updated to reflect this! – Fazer87 – 2014-06-05T13:57:16.413

1If looking for an example proxy that can be used just for this purpose, I would propose Privoxy. – HalosGhost – 2014-06-05T16:11:01.007

0

Path blocking

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

cybernard

Posted 2014-06-05T13:00:27.000

Reputation: 11 200