The hosts text file contains a database of domain names and their corresponding ip. The contents of the file are controlled by the user. A request to this file has higher priority than a request to DNS servers.
By writing the domain and ip in this file, your browser will look for the domain on this ip.
Thus you can, for example, set up a site on a new hosting without redirecting the domain itself, or while the domain is not yet purchased.
The file has a different location on different operating systems:
Operating system | Location | Example |
Unix-подобные | /etc/hosts | |
Windows 95, 98, Me | %windir%\ | c:\windows\hosts |
Windows 2000, XP, Vista, 7 | %SystemRoot%\system32\drivers\etc\ (может быть переопределено в реестре) | c:\windows\system32\drivers\etc\hosts |
Mac OS X | /private/etc/hosts |
Example content:
127.0.0.1 localhost
91.203.4.180 tuthost.ua