Knowledgebase: Domains & DNS
Preview Your Site Without Changing DNS
Posted by CTX Admin on 30 September 2014 12:46 PM

You can add your domain name(s) to your hosts file by doing the following for all local computers:

Note: please remember to remove the entry you added (and ONLY that entry; your computer may not work correctly if you remove all entries!) when you're done testing. This will avoid problems down the road if your account is migrated, assigned a dedicated IP, etc.

Linux (i.e. Ubuntu)

  1. Open an xterm (or any other terminal emulator of your choice)

  2. Type in: sudo nano /etc/hosts (or use any other editor of your choice, such as my personal favorite, vim (hit i to edit text in vim); just be sure to edit the file with root privileges)

  3. Add a line containing xx.xx.xx.xx yourdomain.com, where xx.xx.xx.xx is the appropriate IP address for the server, VPS, etc. (this will most likely be the main shared IP unless you have purchased a dedicated IP) and yourdomain.com is your actual domain or subdomain hosted on that server (do not insert slashes, http://, or the like)

  4. When done, save the document (use CTRL+X to save and exit, which you must confirm by hitting the y key in nano; vi(m) users would hit Esc then :wq)

  5. You should now be able to visit yourdomain.com in a web browser and be able to see the content you have hosted on our servers

To remove the entry...

  1. Follow steps 1 and 2 above

  2. Remove the entry you added (in nano, move the cursor down to the entry and hit CTRL+K to delete the line; in vi(m), move the cursor to the line and hit dd)

  3. Save the document (see Step 3 above for instructions on how to do that)

You're done!

Windows

By default, if you try to modify your hosts file in Vista or Windows 7 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.

  1. Browse to Start, then All Programs, then Accessories

  2. Right-click Notepad, then select Run as Administrator

  3. Click Continue on the UAC prompt
    Note: this prompt will only appear if UAC is enabled. 

  4. Click File, then Open

  5. Browse to C:\\Windows\System32\Drivers\etc

  6. Change the file filter dropdown box from Text Documents (*.txt) to All Files (*.*)

  7. Select Hosts and then click Open

  8. Add an entry like this: xxx.xxx.xxx.xxx yourdomain.com (see Step 3 under the Linux instructions for details)

  9. Save your host's file and you're done

To remove the entry...

  1. Follow steps 1-7 above

  2. Delete the line you had added

  3. Save the file

Mac OS X

  1. Open a terminal by going to Applications, then Utilities, then Terminal

  2. Type in: sudo su -

  3. Press Enter

  4. Type in: echo "xxx.xxx.xxx.xxx yourdomain.com" >> /private/etc/hosts (see Step 3 under the Linux instructions for details)

  5. Press Enter and you're done

To remove the entry...

  1. Follow steps 1-3 above

  2. Type in vi /private/etc/hosts

  3. Press Enter

  4. Use the cursor keys to position the cursor over the line you added above and type dd to delete the line

  5. Type :wq to save your changes and exit

(0 vote(s))
This article was helpful
This article was not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
Help Desk Software by Kayako fusion