Often a web hosting client will sign up with a new HostDime account with the intent of transferring an existing website from another cPanel server over to HostDime, or designing a new website on the HostDime account and then pointing the domain to the new server when the design is finished. This tutorial explains an advanced method for testing your website on a new server before you update the domain name to point to the new server.
Typically, website owners are able to upload their website files to the server and test the website from the server using a special link which is provided in the Welcome email message they received after they signed up for their hosting account
Here is an example of such a link: http://184.108.40.206/~username/
This special link is provided by a module that is installed on the web server known as ‘mod_userdir’. This module makes the specific website on that server available by matching the username in the ‘/~username/’ part of the URL with the actual VirtualHost entry in the servers configuration file (httpd.conf).
This special link works well for those with some static HTML websites, but it causes errors with websites which rely on the domain name being used in the URL (typically PHP or Perl based websites), and HTML sites which use image links which refer to the site root instead of using linking in relation to the location of the file itself (relational link).
Because of this, we do not recommend using this link to test your website to make sure its fully functional.
The advanced method of testing your website is to trick your computer into thinking that your domain is already resolving to the new web server. This can be done with a simple edit of the HOSTS file on your computer.
Long before DNS servers were part of the Internet, all machines kept an updated HOSTS file which contained the name (like a domain name) and the actual network address of the machine that name referred to. After the Arpanet/Internet got too large for this file to be downloaded from a central location by every computer, the DNS system was invented to replace the HOSTS file. Even though this HOSTS file is no longer in use, it still exists on modern operating systems and actually overrides the DNS records your computer receives or has cached.
- On MicrosoftWindows systems this file is located at C:\Windows\System32\drivers\etc\hosts
- For Linux systems its usually located at /etc/hosts
We strongly recommend copying the HOSTS file from the C:\Windows\System32\Drivers\etc folder to your Desktop for safe-keeping, in the case that you need to revert your changes to this file.
Once you find the file, right-click on it and choose to open the file in Notepad or another non-formatted text editor. Word processing software such as WordPad or MS Word are not recommended.
Typically, if you try to open the file, Windows will prompt you to choose which program you wish to open the file with, as the file itself has no extension.
After you’ve opened the file, you should see something similar to the following:
Enter a line which begins with the IP address of your new server, and ends with the domain name for your website, right below the “127.0.0.1 localhost” line. After you’ve done this, enter a line below it which is indentical, but include the ‘www.’ at the beginning of your domain name. We’ve done it using ‘johndoe.com’, with 220.127.116.11 as the IP address of the server.
After you’ve done this, save the file (File > Save), and then close the Notepad program.
If you open a new browser window and try to visit the website, you’ll see that it pulls up the version that is on the new server, just as if the domain was actually resolving to the new server. This is obviously the best way to test your website because it actually emulates the behavior and performance of the website had the domain actually resolved to the new server.
After you are done testing the website, open the HOSTS file up again in Notepad and remember to remove the lines you’ve added. If you forget or do not remove these lines it may lead to problems or confusion for you and any technicians you speak to regarding issues which may arise.