Testing Your Site Before Updating the DNS… HOW TO: Temporary URLS and Updating your Hosts File

We all know the importance of testing your site after a migration to your hosting account.  More often than not we wish to do this prior to updating the domain’s DNS nameservers to Arvixe.   We have a few options that allow us to do this – via the control panel, as well as by modifying your local PC’s hosts file.

Both cPanel and Website Panel provide temporary URLs via the hostname.

The cPanel (Linux) Temporary URL:

Every cPanel user’s main domain is accessible via the hostname of the server and their username.  For example:

<a href="http://servername.arvixe.com/~username">http://servername.arvixe.com/~username</a>

(You will need to replace the “servername” with the actual hostname of the server, as well as “username” with your cPanel user to utilize this).

The following addresses will bring you to the contents of your main public_html folder, you can append subfolders to the URLs for further testing if needed, for example:

<a href="http://servername.arvixe.com/~username/subfolder/anotherfolder/yetanotherfolder/">http://servername.arvixe.com/~username/subfolder/anotherfolder/yetanotherfolder/</a>

The WebsitePanel (Windows) Instant Alias:

Each domain that you add inside of WSP has the option to use or disable the “Instant Alias” – which is the Website Panel terminology for a temporary URL.

This is accessible via the following, also using the server’s hostname, for example:

<a href="http://mydomainname.com.servername.arvixe.com">http://mydomainname.com.servername.arvixe.com</a>

(Here you will need to replace your “mydomainname.com” with your actual domain name, and “servername” with the hostname of your server).

This brings you to the main wwwroot folder of the website space for your domain.

The Instant Alias option can be enabled/disabled via WebsitePanel.

1) Go To Domains

2) Click on the Domain Name

3) If the Instant Alias is disabled, you will see a “Create Instant Alias” link; clicking this link will update the screen and enable the instant alias.  If the Instant Alias is enabled, you will see a “Delete Instant Alias” link; clicking this link will update the screen and disable the instant alias.

create_instant_alias

figure 1.  A disabled Instant Alias showing the Create Instant Alias button in the domain properties.

Both of these methods (cPanel and WebsitePanel) are only accessible via the shared IP address of the server, as they utilize the server’s hostname.

If you have a dedicated IP address for your hosting account (either Linux or Windows) you can access your site directly via your dedicated IP:

<strong><a href="http://X.X.X.X">http://X.X.X.X</a></strong>

(Replace X.X.X.X with your actual dedicated IP address).

How To Change your Computer’s Hosts File:

Temporary URLs work well in most cases, but in other cases some content management systems rely heavily on DNS and redirections in order to function properly, making testing via temporary URLs difficult as clicking links will take you to the domain name again, itself.  In cases like this – we update the hosts file for testing on your local PC.

One thing to keep in mind, regardless of which operating system you use at home, you can simply add your host information to the bottom of the file – in the following format:

X.X.X.X   domain.com
X.X.X.X   www.domain.com

X.X.X.X will be the IP address we are going to force your computer (and only your computer) to resolve the domain to. This will be the IP address assigned to the domain name.  Domain.com will be the domain name to test prior to updating the DNS.

Another thing to keep in mind when testing your site using the hosts file method- after updating your hosts file, you will need to clear the cache and cookies from your web browser and restart the browser in order for things to take full effect.  In some instances you may need to flush your DNS cache on the local system as well.

Updating a Hosts File on Windows:

Go to Start  ->  All Programs  ->  Accessories

Right click on Notepad, and select “Run as Administrator”

Click “Continue” at the UAC prompt.

In the notepad application – From the toolbar, go to   File -> Open

Open the Following File:

C:\Windows\System32\drivers\etc\hosts

(This path may vary based on your drive/installation configuration, and you may need to choose the file type to open from the drop down menu as “All Files” in order to see your hosts file).

Add your new host entry to the bottom of the file and save.

change_hosts_file

figure 2.  A Windows 7 hosts file with an example entry added so that mydomain.com resolves to the IP of 1.2.3.4

Updating a Hosts File in Linux:

Open up your favorite terminal application (Most flavors store the default terminal application in the Accessories folder).  Also, in this example we are using the text editor called “nano” which is pre-installed on most linux distributions.  You may also use other text editors such as vim or emacs if you wish.

If you are already logged in as  user root, run:

nano /etc/hosts

If you are logged in as a non-root user, run:

sudo  nano /etc/hosts

Then authenticate with your password to grant root access.

Once the text editor application opens, add your new host entry to the bottom of the file and save.

Updating a Hosts File on a Mac:

You will need to launch your Terminal, which you can search for using Spotlight, or you may also access this via Applications/Utilities

Once the terminal application has launched, type the following into the terminal command line:

sudo nano /private/etc/hosts

Enter the Administrator password.

After the file has opened, add your new host entry to the bottom of the file and save.

Again, make sure you clear the cache from your browser and in some cases the DNS cache may need to be flushed as well.

After you update the DNS for your site, make sure to remove any host entries that you may have added during the process to ensure the domain is resolving in the same manner on your local system as other users on the internet!

Tags: , , , | Posted under cPanel/Linux Hosting, Domain Names, DotNet/Windows Hosting | RSS 2.0

3 Comments on Testing Your Site Before Updating the DNS… HOW TO: Temporary URLS and Updating your Hosts File

  1. n0rbertt says:

    I would recommend using %systemroot%\system32\drivers\etc\hosts as the correct file to edit. With that variable in there the user does not need to have the their system installed to the drive c:\

  2. sam haniff says:

    please let me know if there is anything I have to do or the hosting has been successfully switched over

    • Karen S says:

      An easy way to make sure your domain is resolving to the new IP you set in your hosts file is to open a terminal or command prompt and ping your domain name using the following command:

      ping domain.com

      (make sure to update domain.com with your own domain name).

      This will show you what IP address the domain name is now resolving to on your PC.
      Please remember this is a local change on your PC only. To make DNS changes public after testing you will need to update the domain’s resolving IP at it’s DNS host, or by changing the domains nameservers at its registrar.

Leave a Reply

Your email address will not be published. Required fields are marked *


× 7 = 56

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>