I need to edit my local HOSTS file to redirect my web requests for my web site to my development server rather than the live web server, how do I do this?
Using Windows Explorer, browse to
(older versions of windows go to: C:\windows\hosts)
Locate the file titled “hosts”
Right-click the file, left-click Properties
Select the Security tab, click the Edit button
Select the “Users” group, and check the “Modify” box in the Permissions For Users section below
Click OK, OK
Double-click the “hosts” file to open it, and select Notepad from the Open With program list.
Add the following line to the bottom of the file:
(replace 22.214.171.124 with your web site’s IP Address, and replace anySiteSolutions.com with your web site’s domain name)
Save the file
Now close all web browsers, open a new web browser, type in your web site’s address, and you should be directed to the new site.
**Be certain to update or remove this line when you are ready to move to the live Internet address.
MACINTOSH / APPLE
Open the Terminal
–Search for Terminal from Spotlight (launch spotlight by holding down the Command key and pressing the space bar)
In the Terminal window type the following command:
sudo nano /private/etc/hosts
You will be prompted to enter your logon password again.
The file now loads in the terminal window where you will need to use your arrow keys to navigate to the bottom of the text file and add the IP and hostname you want to add. Example:
When you are done editing the file, hold down the control key and press the X key to exit the editor.
Press the Y key to answer Yes to save the file (the actual message is ‘save modified buffer’, but it just means save file)
Press the enter or return key at the next prompt (File Name to Write)
At this point you are returned to the standard Terminal prompt.
From here you can close the window, or enter the following command to close the window: killall Terminal
USE THE FINDER
Select the Go To Folder… command (Shift + Cmd + G) from the Go menu
in the Go to the folder: text box
Find the Hosts file and copy it to the desktop
Open the copy on your desktop, and edit the entries you wish to change (see notes in previous section) and save the file
Copy the file back to the /private/etc folder
When prompted to authenticate, press the button to replace the file and enter your password.
Test Web Site