Did you know that there is a very handy method to allow you to view and test your new or updated web site before submitting a DNS change request to your registrar? This simple addition to the “hosts” file on your PC or Mac re-direct any internet requests to the IP address of your choice, for example a new server, directory, or sub-domain.
Simply add this code to your hosts file. That’s it.
127.0.0.1 yoursite.com
127.0.0.1 www.yoursite.com
Now, whenever you browse to your domain name you will be re-directed seamlessly to your development server.
Setting up the Hosts file on a PC
- Click the Start Menu button and then type the word “notepad” in the Search area.
- Right click on the “Notepad.exe” icon that appears and choose “Run as administrator“
- Click “File > Open” using Notepad and navigate to the “Windows > System32 > drivers > etc” directory.
- Click the drop-down field titled “Files of type:” and choose “All Documents (*.*)”
- Open the file titled “hosts“
- Add the following entries at the end of the Hosts file:127.0.0.1 yoursite.com
127.0.0.1 www.yoursite.com - Save this “hosts” file. Note: Click through any warnings that pop up, if any.
- Reboot the computer.
Setting up the Hosts file on a Mac
- Look in the System Folder: Preferences and also in the System Folder for a file named “Hosts“. If it does not exist, create this file using a text editor.
- Add the following entries into the Hosts file:127.0.0.1 yoursite.com
127.0.0.1 www.yoursite.com - Save this Hosts file into the System Folder: Preferences
- Reboot.
If you have an older Mac that is using MacTCP instead of Open Transport, you may need to put the Hosts file in the System Folder.