How to block websites in localhost file?
That's the wrong format. You cannot use URLs in hosts
only machine names.
Eg. this entry would be OK:
127.0.0.1 searchmagnified.com
which would redirect all connections for searchmagnified.com
to localhost
(not just HTTP, everything).
It also relies on there being nothing running on localhost
to respond, eg. if you are running IIS, then it will respond (possibly with an error) to the redirected requests.
You can use WWW
but not the http:
.
127.0.0.1 www.yahoo.com
We are telling our local machine that Yahoo actually exists on the local machine. Any request for www.yahoo.com
will be directed to the local machine and therefore effectively blocked. You could also use the IP of another website if you wanted to be creative.
Let’s take a closer look at a URL http://www.yahoo.com
http://
defines the transfer protocol in this case Hyper Text Transport Protocol; this is the standard for viewing websites. Another common protocol is ftp://
for file transfer.www
is the hostyahoo.com
is the domain.com
is further classified as the TLD (Top Level Domain)
A HOSTS file entry will disregard the transfer protocol so it isn’t needed. However, the host does play an important role. A webmaster may choose to define a host for his/her website. WWW
has become the universal standard for the default host. It is just as common to define a site with no host as well. This means that as far as DNS goes www.yahoo.com
& yahoo.com
are two totally different sites, even though they resolve to the same place. Because of this to effectively block the site, you must also block all hosts. This would usually mean:
127.0.0.1 yahoo.com
127.0.0.1 www.yahoo.com