Block specific url paths

blockinghosts-file

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?

Best Answer

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.

Related Question