Modifying your hosts file will allow you to override the DNS for a domain, on that particular machine. This can be used to test your site without the test link, prior to going live with SSL, verify an alias site works prior to DNS changes, or for other DNS related reasons. This causes your local machine only to look directly at the IP specified.
Your hosts file will need to have two entries added that will contain the IP address you want the site to resolve to and the address. Adding the below two lines for example will point www.domain.com and domain.com to our current PHP5-ITK (“Refreshed” PHP5) cluster:
49.0.37.70 www.domain.com 49.0.37.70 domain.com
Below is how to locate and edit the hosts file on several OS platforms. Once the proper domain information is added you will save the file and your system will begin resolving to the specified IP. Once testing is finished these entries should be removed.
Contents:
- Windows Vista and Windows 7
- Windows NT/2000/XP
- Linux
Windows Vista and Windows 7
Vista and Windows 7 use User Account Control (UAC) so Notepad must be run as Administrator.
- Click Start -> All Programs -> Accessories
- Right click Notepad and select Run as administrator
- Click Continue on the “Windows needs your permission” UAC window.
- When Notepad opens Click File -> Open
- In the filename field type C:\Windows\System32\Drivers\etc\hosts
- Click Open
Windows NT/2000/XP
- Click Start -> All Programs -> Accessories -> Notepad
- Click File -> Open
- In the filename field type C:\Windows\System32\Drivers\etc\hosts
- Click Open
Linux
- Open a terminal window
- Type sudo nano /etc/hosts (you can substitute any text editor)
- Enter your password