Testing Your Site Before Updating the DNS… HOW TO: Temporary URLS and Updating your Hosts File
Written by Karen S Thursday, 21 February 2013
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:
(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:
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:
(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.
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:
(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 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:
(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.
figure 2. A Windows 7 hosts file with an example entry added so that mydomain.com resolves to the IP of 22.214.171.124
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:
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!