Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I edited my localhost file to block the last two websites (text in bold) but mozilla still connects to them. For example: when i'm trying to go to latestdownload.org it switches me to this search black friday thing...can someone look and tell me what I did wrong and how to correct it so that it works. Thanks

#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost

**127.0.0.1 http://searchmagnified.com
127.0.0.1   http://searchmagnified.com/?dn=blackfridayeveryday.info&fp=2j89hM9NN374n04BRBX%2Bhz5DsUH8KrqD%2B61pScTW%2BtCm8hlQlisunD4XsyoEAhNOqtQQnztm65aCVYHd5705AQ%3D%3D&prvtof=xSt4De0710HIVzV3r4oJXTYRNmGKp5oOIOMC43%2BYZqH1hufFQfaEioz44OkBxZ1KCbqv2SqaMXgKKD2Si6qt8sGjaIvMpvR%2FXmJlXXTgWEgiz8ZtoaLKW0GOLsnAN6ye&poru=cDEmaPRsJFXpjVEX50b6uEXpEkLx0jNpkIf0ytZnAXeHoLCSeQMRC%2FhAUlpR6sUx6ttXi7u8%2BCO2pnuWOqE9daXTm4CrjKIj7Tst2olm0mc%3D&cifr=1&**
share|improve this question
    
localhost is intended to serve resolution of local names, not to do site blocking. In fact, one could still go to the banned sites using the numerical IP. The proper way to do such a blocking is by means of some firewall, such as IP Tables. –  zakmck May 21 '12 at 18:02
add comment

2 Answers

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 host
yahoo.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

share|improve this answer
add comment

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.

share|improve this answer
8  
Also, sometimes you have to clear the DNS cache with ipconfig /flushdns. +1 –  jmort253 Apr 9 '12 at 8:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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