Forwarding Websites

posted November 1, 2012 by daniel

When you're working on a website and want to be able to access the site before the DNS has changed, there's a relatively easy way to do it. First, open the Terminal application (search for it with Spotlight). Don't worry if you're not an expert with Terminal — this is easy to do. In Terminal, type sudo nano /etc/hosts and press enter. Since this is a protected system file, you'll need to enter your password to be allowed to edit the file.

The host file is a simple text file with one website on each line. The first few lines are special entries that should not be changed, so move the cursor down to a blank line. Enter the IP address of the website you want to forward (or if the website should forward to your own computer, enter, then tab over (or type a few spaces), then type the name of the website.

When you're done making changes, press control-x to quit. The text editor will ask if you want to save, so press the letter Y for yes, then press enter to save with the original file name. That's it! Now, when you load the website in your browser, it will be loaded from the IP address you've entered into the hosts file. No need to reboot or even restart the web browser.