The Hosts file is like an address book. When you type an address like www.yahoo.com into your browser, the Hosts file is consulted to see if you have the IP address, or "telephone number," for that site. If you do, then your computer will "call it" and the site will open. If not, your computer will ask your ISP's (internet service provider) computer for the phone number before it can "call" that site. Most of the time, you do not have addresses in your "address book," because you have not put any there. Therefore, most of the time your computer asks for the IP address from your ISP to find sites.
To find the location of hosts file, look at the following location for each operating system.
Win95/98 hosts file location:
Windows 95/98/Me c:\windows\hosts
Win2k hosts file location:
Windows NT/2000/XP Pro c:\winnt\system32\drivers\etc\hosts
XP hosts file location:
Windows XP Home c:\windows\system32\drivers\etc\hosts
To open a hosts file, right click on the file and select Open. You will be prompted to choose a program to open the file with. Select Notepad.
The hosts file consists of an IP-address to which the browser is to go to when the domain name after is entered in the browser address line.
Ex: (from a hypothetical hosts file)
The IP-address 127.0.0.1 is the machine's local address. This means that the first line blocks all contact with annoying-commercial.com by linking it to the computer self. This will give the browser a busy signal, and it will give up trying to find it. Hence any links to annoying-commercial.com won't make it to your machine. This is a usual way of blocking unwanted advertising web pages.
By entering anypage.com in the address line, your browser will be directed to 184.108.40.206 which is the Yahoo directory.
Editing the Hosts file on Windows Vista and Windows 7
1. Open Notepad with Administrative privileges by clicking Start, All Programs, Accessories, and then right-click Notepad and select to open as Administrator.
2. Now that Notepad is open with Administrative privileges browse to (C:\Windows\System32\drivers\etc) in Notepad and open the hosts file.
Now you can edit and save the hosts file.