Changing your hosts file on Windows
During development and testing phases of the web development projects, one might need to direct a certain domain to a new IP address without making a global DNS change. Enter the HOSTS file! Simply add the following line to that file (using your own IP and DOMAIN)
and voila… the domain now points to the new server. Obviously this only affects your local machine. Here are the locations of the HOSTS file on various operating systems:
- Windows 95/98/Me – c:\windows\hosts
- Windows NT/2000/XP Pro – c:\winnt\system32\drivers\etc\hosts
- Windows XP Home / Windows 7 / Windows 10 – c:\windows\system32\drivers\etc\hosts
On Windows Vista, Windows 7 and Windows 10 it gets a bit tricky… By default, if you try to modify your hosts file in Windows 10, it will not let you save it. It tells you that you don’t have permission. To successfully modify the hosts file, run notepad.exe as an administrator and open the file.
- Browse to Start -> All Programs -> Accessories
- Right click “Notepad” and select “Run as administrator”
- Click “Continue” on the UAC prompt
- Click File -> Open
- Browse to “C:\Windows\System32\Drivers\etc”
- Change the file filter drop down box from “Text Documents (*.txt)” to “All Files (*.*)”
- Select “hosts” and click “Open”
- Make the needed changes and close Notepad. Save when prompted.