You’re developing a site on a sub-domain or development server that is setup something like this, and you want to see if all the files and paths are correct. You’ve moved the site to a new server and IP and you want to check there without disrupting the live site. Simply edit your /private/etc/hosts file on your Mac OS X box to reflect the new IP you want to test.

Real Live Site: IP
Dev Site: IP
DNS Masked Site: IP

Simply edit /private/etc/hosts and add the line

Now when you ping your system will return Open up your browser and test your new site before making the DNS switch on the real DNS servers.

The hosts file is used to map hostnames to IP addresses. With the hosts file you can change the IP to which you resolve a certain domain name.

This is particularly useful when you wish to see how a website will look when hosted on a different server without having to wait for a DNS change to propagate, or avoiding any DNS changes at all.