The hosts file is used to map domains to IP addresses. This change only affects your own computer without affecting where the domain is accessed from worldwide.
This is useful when you wish to see how a website will look like when hosted on a different server or when developing using a test site. It can also be helpful when migration from one CMS to another (i.e. Blogger to Wordpress)
The location of the hosts file is dependent on your operating system:
-
Windows - SystemRoot > system32 > drivers > etc > hosts
By default the system root is c:Windows, so if you are using Windows, your hosts file is most probably: C:\Windows\System32\drivers\etc\hosts) You'll need to open the file as an administrator in order to edit it. - Linux - /etc/hosts
- Mac OS X - /private/etc/hosts
If you want testdomain.com to look for the site on the server with an ip address of 1.1.2.2 instead of wherever the site is currently located, you would need to open up the hosts file with a text editor and add the line:
1.1.2.2 testdomain.com www.testdomain.com
This will tell your computer to resolve testdomain.com to 1.1.2.2. If you try to reach your domain in a browser it should take you to the site hosted on the server with IP 1.1.2.2, you may need to clear the browser cache first.