Redirect or block sites using HOSTS file
You can redirect or block one or more web sites using the HOSTS file in Windows. The HOSTS file is located in the folder C:\Windows\System32\drivers\etc in both Windows XP and Vista. It is basically a text file with two columns : the first column consists of a target IP address and the second column consists of the respective source site address. When you access a site listed in the second column, you are redirected to the respective site in the first column. The two columns should be separated atleast by a single space. A typical HOSTS file is shown below :

Because localhost is in the second column and the corresponding entry in the first column is 127.0.0.1, when you type localhost in your browser's address bar, it will be redirected to 127.0.0.1. You can use this technique to block or redirect some undesirable sites, for example, pornographic sites, advertisement sites or malware sites.
Blocking a web site
Lets assume that you want to block a site www.gooogle.cn, you can edit your HOSTS file using the following steps :
- Open Start Menu · Run and type notepad c:\windows\system32\drivers\etc\hosts and press Enter as show in the picture :

- This would open yuor hosts file in Windows' Notepad. Start editing at the end of the file : Press Enter to start a new line. Type 127.0.0.1. Press TAB key once. Then type the name of the site you want to block, in this case, gooogle.cn. You do not have to type the http:// or www. part of a web site. Then end result will look like this :

- Save the hosts file. Now when you type gooogle.cn in your browser, it will be redirected to 127.0.0.1 and you wont be able to access it.
This way you can block phishing sites, infected sites, porn sites and certain ad servers as well. Actually, this is a popular way of blocking Paltalk (http://www.paltalk.com) advertisements. Just block advertising.paltalk.com in your hosts file and you won't see most of the advertisements in Paltalk basic.
Redirecting a web site
You can redirect a web site to another site using the same method as described above for blocking, except replace 127.0.0.1 by the target site address. For example, suppose you want to redirect your browser to www.google.com whenever someone types www.playboy.com in the browser address bar, then follows these steps :
- Open hosts file in Windows' Notepad as described in the blocking section step 1 (see above).
- Find out IP address of www.google.com using this article : Find the ip address of a site. (IP address is found out to be 74.125.53.100)
- Start editing at the end of the HOSTS file : Press Enter to start a new line. Type 74.125.53.100, press TAB key once followed by playboy.com. Save the hosts file.
Now whenever you (or someone else) types in your browser's address bar www.playboy.com, he/she will be redirected to www.google.com.
Readymade HOSTS file
Some people have prepared a hosts file which blocks thousands of sites linked to parasites, malware, adware and spywares. This is a very useful way to stay safe on the internet, as with such a hosts file, all malicious sites will be blocked. You can download this readymade HOSTS file and read instruction on how to install it on http://www.mvps.org/winhelp2002/.
Leave a Comment