Amaze Hosting Information Centre

Moving Websites? Here’s How to Preview Your Website before Taking the Plunge

Posted on
Locate-the-hosts-file

At some point in time, every business will need to move their website to a new hosting provider. Mostly this is accompanied by a new website design or update to the existing CMS.

It is important to make sure that the website is up and running without any glitches before you switch the DNS to the new server and make it available to the whole world.

Here are the step-by-step instructions to preview a website on your new website hosting before switching DNS.

The most common method to inspect a website before migrating is by modifying hosts file.

The hosts file is a local computer file used by an operating system to map hostnames (domains) to IP addresses. Editing this file allows you to override your computer’s DNS system for a domain on a certain machine. This way you can edit or work on your website hosted on the new server while your users are still directed to the active website on the old server.

Note: Before changing files, close the browser.

Here’s how you can edit hosts file on different operating systems:

For Windows 7, Windows 8 and Windows 10 Users

  • Locate the hosts file on your computer. For windows users, it is typically located at;

Folder C:\Windows\System32\drivers\etc

Locate-the-hosts-file
  • Double-click on the ‘hosts’ file and choose Notepad from the list of available programs to open the file with.
Double-click-on-the-hosts

 

  • Type in the IP of your new web host and then your domain name in the following way:

IP_address domainname.com
IP_address www.domainname.com

Here, IP_address is the IP address of your account on the server and domainname.com is your actual domain name.

IP-address

 

  • When finished, save changes.
  • Next, clear the browser’s cache and re-open your domain name on the new server to see the changes.

Alternatively, you can:

  1. Open Notepad with Administrative privileges by clicking the Start
  2. Find Applications> type Notepad in the search bar and then right-click on Notepad and select Run as Administrator.
  3. In Notepad, click the File menu > choose Open.
  4. Browse to Folder C:\Windows\System32\drivers\etc. Alternatively, you may also copy the given path onto the address bar and click Enter.
  5. Click All Files to locate the hosts file.
  6. Follow the steps 2-6 as mentioned in the previous instructions.
Administrative-privileges

 

For Mac Users

  • Open Terminalinside of your Utilities Folder either by clicking Applications > Utilities > Terminal or simply typing Terminal on the Spotlight.
Utilities-Folder
  • Back up your existing hosts file to be on the safe side. Copy and paste the following command and hit return:

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

  • After you have a backup copy, you can edit your hosts file. Copy and paste the following command and hit return:

sudo nano /private/etc/hosts

  • Type your user password when prompted.
user-password
  • Your hosts file will appear on the screen which looks something like this:
    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
  • Edit the hosts file by adding your domain name and IP address below the default ones in the following way:
    IP_address domainname.com
    IP_address
    www.domainname.com
domain name and IP address
  • After you have made the changes, press Control + O to save the file, Control + Xto exit the editor.
  • You need to now flush your DNS cache by typing the following command and pressing return:

dscacheutil -flushcache

Once done, close your browser, and re-open to view your website on the new server.

Amaze