Let us assume for this example your testing server has an IP address 18.104.22.168 and you wish to visit that server when you type “http://example.com” into a web browser BUT still wish to still see the site as the rest of World Wide Web does when you enter “http://www.example.com” into your browser instead.
- Open a text editor such as Notepad (all programs>accessories).
Windows 7 and later: Right-click on Notepad and select the option to Run as Administrator – otherwise you may not be able to open this file. If you don’t have the run as Administrator option it means you don’t have these privileges. Contact your IT person to get them or to set up the local host for you.
- Locate the HOSTS file on your computer. Typically it is in one of the following locations:
- Windows NT/2000/XP/2003/Vista/7 – C:windows/system32/drivers/etc/hosts
- Windows 95/98/Me – C:windowshosts
- Then, open the file. Consider performing a “Save As” so you have an original copy of the file that you can restore later. You will see two columns of information, the first containing IP addresses and the second containing host names. By default, a windows hosts file should be similar to the following:
(In Windows 7 Press and hold Ctrl+Shift while opening the Notepad/Wordpad).
You can add additional lines to this file that will point requests for a particular domain to your new server’s IP address.
- Save your changes (be sure to save as a host file, not as a text file).
Windows wants to save it as text (.txt) so you need to
- Change save as type to all files and then
- Click on host (the original file).
- Restart any currently open browsers.
- You may also want to flush your DNS cache. In Windows XP, go to Start, and then Run, then type “cmd” and hit enter.
Type the following:ipconfig /flushdns
- In your web browser you should see your site as it appears on your testing server when typinghttp://example.com/ but still be able to see the site on its current web server by visiting http://www.example.com/