How To Preview/Test Website Before DNS Updates

To test your website with your own domain name before DNS propagation has completed, you can use your local computer’s ‘hosts’ file.

Your computer will use the entries in your ‘hosts’ file before it looks up the DNS information for your domain. This article contains instructions for editing the ‘hosts’ file on Windows /XP/Vista/7, and Apple’s Mac OS X.

Windows

1. Locate the HOSTS file on your computer

Windows /XP/Vista/7 – C:\windows\system32\drivers\etc\hosts

2. Open this file with a text editor such as Notepad or Wordpad.

*right-click on Notepad and select the option to Run as Administrator – otherwise you may not be able to open this file

By default, a windows hosts file should be similar to the following:

# Copyright (c) 1993-2006 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

#---------------------- DO NOT DELETE ----------------------------
127.0.0.1       localhost
#::1             localhost

You can add additional lines to this file that will point requests for a particular domain to your new server’s IP address. Example:

77.22.87.202 blog.example.com
77.32.88.203 example.com
77.32.88.203 www.example.com

3. Save your changes.
4. Restart any currently open browsers. You may also want to flush your DNS cache. In Windows, go to Start, and then Run, then type “cmd” and hit enter. Type the following:

c:\>ipconfig /flushdns

5. Visit your new site using http://example.com/  or http://www.example.com/

 

Mac OS X

1. Open Terminal, which is in Applications, then the Utilities folder.

2. You may want to first make a backup copy of your existing hosts file:

sudo cp /private/etc/hosts /private/etc/hosts-orig

3. Enter your user password at the prompt.

4. Type the following command to edit your hosts file:

sudo vi /private/etc/hosts

5. Enter your user password at the prompt.

6. You will see a file with contents similar to the following:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost

7. Add your domain and IP address to the bottom of the file. For example:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
77.22.87.202 blog.example.com
77.32.88.203 example.com
77.32.88.203 www.example.com

8. You may also need to grant yourself sudo priveleges, if you got a permission error in Step 2. In your “Help” menu, search for “root” and select the instructions for “Enabling the root user.” Follow these.

9. Restart any currently open browsers. You may also want to flush your DNS cache:

dscacheutil -flushcache

5. Visit your new site using http://example.com/  or http://www.example.com/

 

Share and Enjoy !

0Shares
0 0 0