How to test your website after migration
A common question, usually just after a person has migrated their website data from one server to another is, “How can I test my sites to see if the migration was successful?” Ah, an excellent question and I’m glad you asked! It is extremely important to test the functionality of your site before changing the DNS to point to the new server.
There are two common methods, use a temporary URL or edit your hosts file. While I will discuss both, I am only recommending the first, that is, change your hosts file.
How to edit your hosts file
The one sure way to verify your migration was successful, is to change your hosts file. This can be performed on Windows, Linux and Macs. This method tells your browser to ignore the publicly available DNS and to use a specific IP that you designate. By using this method, your javascript, css and all other aspects of your site are served from the correct server and everything should perform as expected.
When editing your hosts file, you must use fully qualified domain names. i.e. www.domain.com
Wild card characters (‘*’) are NOT allowed!
Windows Server 2008, Windows 7 and lower
Click to view Windows InstructionsOpen File explorer by right-clicking on then select “Open Windows Explorer”
Inside Windows Explorer, navigate to the following folder:
Computer > Local Disk (C:) > Windows > System32 > drivers > etc
Right click “hosts” and select “Open”
If prompted, select Notepad then click . Notepad should be the default, so do not be alarmed if this step is not required and you can skip to the next step.
Scroll to the bottom of the file and add a line similar to the line displayed.
Replace “mydomain.com” with the actual domain name
Save the file and close Notepad. File > Save
Finally, completely close all instances of your browser and reopen it. You should now be able to enter you domain name in the address bar and view the site at its new location.
Linux
Click to view Linux Instructionssudo /etc/hosts
Add a line at the bottom of the file similar to the example below.
Replace “mydomain.com” with the actual domain name
IP.ADD.RE.SS mydomain.com www.mydomain.com
Save the file and close it. If you are using Nano, use
Mac OS X
Click to view Mac Instructionsnano /private/etc/hosts
Add a line at the bottom of the file similar to the example below.
Replace “mydomain.com” with the actual domain name
IP.ADD.RE.SS mydomain.com www.mydomain.com
Save the file and close it. Use
Temporary URLs
Temporary URLs are often made available when using a control panel such as Plesk or WHM/cPanel, with each using a different method. While temporary URLs allow you to access your files via a browswer, they do nothing to help with any hardcoded links in your site that link back to the website’s domain name. Because of this, you might find that often the javascript or css files do not load and the site does not perform correctly. This method also often fails when using PHP sessions.
Plesk
click to view Plesk instructionsPlesk Version 10 or higher
Replace “mydomain.com” with the actual domain name
https://IP.ADD.RE.SS:8443/sitepreview/http/mydomain.com/
Plesk Versions 8 though 9
Replace “mydomain.com” with the actual domain name
http://IP.ADD.RE.SS/$sitepreview/mydomain.com/
Plesk Subdomains
Plesk Temporary URLs do not work with subdomains, such as blog.mydomain.com. To view a subdomain, see the section “Edit Hosts File”
WHM / cPanel
Click to view WHM / cPanel instructionsReplace cpanelUserName with the cPanel username you assigned in WHM
http::IP.ADD.RE.SS/~cpanelUserName/
or
https::IP.ADD.RE.SS/~cpanelUserName/
Comments
So empty here ... leave a comment!