Yes, you can test your migrated website before making that final DNS changes!

 

You can do this by adding a line in your hosts file. Modifying your hosts file allows you to override the DNS for a domain, forcing your computer to translate a domain to a specific IP, without ever asking the DNS servers.

This override will affect only the computer with the modified hosts file. This is useful when you want to test a migrated website before you change your DNS or going live with SSL.

You need to add a line to your hosts file that contain the IP address that you want the site to resolve to and the address. Adding the following line, for example, point www.domain.com and domain.com to IP 123.123.123.123:

 

123.123.123.123 www.domain.com domain.com

 

The following sections provide instructions for locating and editing the hosts file on several operating systems. After you add the domain information and save the file, your system begins resolving to the specified IP address. After testing is finished, remove these entries.

  • Windows 8, Windows 7, and Windows Vista
  • Windows NT, Windows 2000, and Windows XP
  • Linux
  • Mac OS X 10.6 through 10.8

 

Windows 8, Windows 7, and Windows Vista

Windows 8, Windows 7, and Windows Vista use User Account Control (UAC), so Notepad must be run as Administrator.

 

For Windows 8

  1. Press the Windows key.
  2. Type Notepad in the search field.
  3. In the search results, right-click Notepad and select Run as administrator.
  4. In Notepad, open the following file: c:\Windows\System32\Drivers\etc\hosts
  5. The file already contains some lines, add your line in the end of the file in a new line
  6. Click File > Save to save your changes.

For Windows 7 and Windows Vista

  1. Click Start > All Programs > Accessories.
  2. Right-click Notepad and select Run as administrator.
  3. Click Continue on the Windows needs your permission UAC window.
  4. When Notepad opens, click File > Open.
  5. In the File name field, type C:\Windows\System32\Drivers\etc\hosts.
  6. Click Open.
  7. The file already contains some lines, add your line in the end of the file in a new line
  8. Click File > Save to save your changes.

Windows NT, Windows 2000, and Windows XP

  1. Click Start > All Programs > Accessories > Notepad.
  2. Click File > Open.
  3. In the File name field, type C:\Windows\System32\Drivers\etc\hosts.
  4. Click Open.
  5. The file already contains some lines, add your line in the end of the file in a new line
  6. Click File > Save to save your changes.

 

Linux

  1. Open a terminal window.
  2. Open the hosts file in a text editor (you can use any text editor) by typing the following line: 

     

    sudo nano /etc/hosts

     

  3. Enter your password.
  4. The file already contains some lines, add your line in the end of the file in a new line
  5. Press Control-x.
  6. When asked if you want to save your changes, answer y.

 

Mac OS X 10.6 through 10.8

  1. Open Applications > Utilities > Terminal.
  2. Open the hosts file by typing the following line in the terminal window: 

     

    sudo nano /private/etc/hosts

     

  3. Type your user password.
  4. Edit the hosts file. The file already contains some lines, add your line in the end of the file in a new line
  5. Save the hosts file by pressing Control+x and answering y.
  6. Make your changes take effect by flushing the DNS cache with the following command: 

     

    dscacheutil -flushcache