How to Edit Your Hosts File – Test Your New Website Before Going Live
On Windows XP/2003/Vista/7 this file is located in:
With Vista/Windows 7 you will need to edit this file with administrative privileges. You can do this by following one of these two sets of intructions:
- Click on the Windows logo.
- Search for ‘notepad’
- Right click on the notepad launcher and select ‘Run As Administrator’
- Click File, then Open
- Browse to the folder mentioned above and select the hosts file
Alternatively in Windows 7 copy %SystemRoot%\system32\drivers\etc\ and paste the text into the search box (see step 1 above). Right click the hosts file and choose “Open File Location” and edit as above.
Note: While the hosts file edits are in place you will not be able to visit your active site from your computer. You will either need to remove the edits, work with 2 hosts files or just use another computer.
Why would you want to do this? This is useful when moving websites to a new host. This would allow you to recreate your site at the new host and browse to it as though it’s live.
Here is a typical Hosts file
# Copyright (c) 1993-2009 Microsoft Corp.
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
# This file contains the mappings of IP addresses to host names. Each # entry should be kept on an individual line. The IP address should # be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one # space.
# Additionally, comments (such as these) may be inserted on individual # lines or following the machine name denoted by a ‘#’ symbol.
# For example:
# 22.214.171.124 rhino.acme.com # source server
# 126.96.36.199 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
To modify the hosts file to point to your test site simply add a line with your new servers ip followed by a space with your sites domain
188.8.131.52 mycoolsite.com www.mycoolsite.com