How to move your website to a new host

Are you looking for a new web host for your website? If you're planning to move to another host, here's a perfect guide that can help you how to move your website to a new host.

Moving your website is something similar, only a virtual version. You shop for a new location, sign the paperwork to rent hosting space, package up your site to ensure that all of your assets come with you, transfer everything to your new web host, and then point your domain to your new host by changing the DNS record; this final step is in essence hanging the sign over your new shop door.

Switching your host requires completing a series of actions in a specific order to ensure that everything transfers over properly. To move your website to a new host, complete the following steps:

Purchase a new web host

There are a variety of hosting providers out there, each with its own configuration. You will need to evaluate which is right for you based on a number of factors, such as cost, required space, and server configuration, to name a few. When purchasing, consider registering your domain to a third party provider so that in case you do ever need to switch hosts again, your domain can come with you more easily and without any potential complications.

Back up your sites to the new web host

Static files comprise any type of file that does not frequently change, automatically or via a content editor – such as in-place graphics or copy. To back up a static website, simply copy the old file structures over to the new web host.

For a dynamic site that runs on database (ie. MySQL), install the web apps to the new web host as they are currently held in the existing site; then move the database file to the new web host. In case your web application provides easy transfer functionality (as is the case in WordPress’ import/ export function), transfer all of your data files directly to the new web host. If your application does not offer any such functionality, you will need to tweak your MySQL and PHP configuration files accordingly.

Another easy way to move CMS sites (WordPress, for example) is to zip and move everything in your “public_html” or “www” folder to the new web host and add the following two lines into your WP-config:

define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST']); define('WP_HOME', WP_SITEURL);

Final Check Before Making the Move

Double check that everything is working properly on your website once you have loaded your files onto the new hosting configuration.

Of note, you can preview your newly hosted website using a temporary URL in IP numbers. Some hosting companies will even provide a development staging platform so that you can easily and fluidly preview your site before taking it live in the new environment, allowing you to remedy any problems behind the scenes.

Switch Website DNS Records

Switch your website’s DNS record to the new web host’s servers at your registrar.

Your DNS record is more or less a list of instructions that specifies where to send the user; moving your DNS record to the new servers ensures that visitors will find your site as intended, rather than receiving an error or misdirect. This is a critical step – make sure you get the right DNS info from your new web host.

Wait for the DNS change to propagate through the net

Once you have requested to move your DNS record, the switch can take anywhere between a few hours to a full day to take live. Once the switch go live, alert your former hosting company as to the cancellation.

Important Things To Watch For:

Unfortunately, anytime that you change a configuration that affects your website, there are a series of problems that may occur. Keep your eyes out for the following as you prepare for and execute the switch, as well as for a period of time after switching hosts.

1. Downtime
In the WWW, any time that your site is not live is time that you are losing potential readers and potential business – after all, time is money. The goal in general – never mind when you are switching web hosts – is to have zero downtime. To ensure that you do not experience downtime while making the switch, take the time upfront to ensure that everything is in place and working correctly at your new host before fully converting the files and making your site active in its new home.

Secondly, inform your loyal visitors and/or clients that you are switching hosts beforehand along with information about the hours that you are making the switch. Hopefully this will reduce the number of site visitors during the switch time period, eliminating strain on the system and also prevent any customer service headaches in case downtime does occur.

Finally, work closely with your new host throughout the transfer process. If you have any doubts or any questions, do not hesitate to ask your new host for assistance; not only does this speak to the importance of quality customer service, but some web hosts will help to transfer the FOC.

Once the switch is done, it’s recommended to monitor your site uptime closely for a period of time to ensure everything at the new host is working alright.

2. Change of site structures and missing links
As you transfer your site’s assets from the previous hosting environment, it is possible for assets, such as graphics to be misplaced or for certain files to be left behind. If this happens, your visitors are likely to experience 404 errors. Keep an eye on the 404 log during and after the switch – this log will alert you of any non-working links or assets that you need to remedy to restore your site to being fully functional.

Tip:  Repairing site navigation with .htaccess
You can make use of .htaccess redirectMatch and redirect to point old file locations to new ones. The following are some sample codes you can make use of.

Define your 404 page
To minimize the damage cause by broken links – where moved.html is the page you wish to show your visitors when there’s a 404 error.
ErrorDocument 404 /moved.html

Transferring a page to a new location
Redirect 301 /previous-page.html http://www.example.com/new-page.html

Transferring entire directory to a new location
redirectMatch 301 ^/category/?$ http://www.example.net/new-category/

Redirecting dynamic pages to a new location and just in case you change your site structure at the new host –
RewriteEngine on
RewriteCond %{QUERY_STRING} ^id=13$
RewriteRule ^/page.php$ http://www.mywebsite.com/newname.htm? [L,R=301]

3. Emails
Perhaps one of the most difficult parts of switching your web host is transferring your email. There are three common hosting scenarios that apply to email:

Scenario #1: Email is currently hosted on a domain registrar (such as GoDaddy)
This is the easiest scenario from which to move; all you need to do is to switch the A (or @) record and point it to the new host’s IP address.

Scenario #2: Email accounts are hosted with a third party (such as Microsoft 365)
Ensure that your MX records, along with any other records that your email service provider needs, are updated in your DNS.

Scenario #3: Email accounts are hosted with the respective web host
When you make the switch to the new host, simply recreate the existing email account on the new web host and configure the new email agent.

4. Database

There’s risk where your database could be corrupted during the switch. For the ease of discussion we will focus on just WordPress in this point.

What to do when your WP database is corrupted?

In case that you can still access your WP dashboard, try to first disable all plugins and see if your database pulls up correctly. Then, re-enable them one at a time, checking the home page each time to make sure it is showing correctly.

Things would get a little trickier if you cannot access your dashboard. Try these different simple steps to see if one works:

  • Reupload your database, writing over the new database.
  • Check where the corruption error is coming from and try to reupload that file from your old site to your new one.
  • Open the file and check to make sure it is pointing to your new server.

WordPress auto database repair

If those steps do not work, you may have to do a bit of coding, but I’m going to talk you through it. First, open the new site in FTP and go to your wp-config.php file. The file should be in the main folder where you blog resides.

The first thing you should always do whenever editing your PHP files is to make a copy of what is there. You can copy and paste into Notepad and save on your desktop. This could save you if your files get really corrupted.

Look for this wording:

/** Absolute path to the WordPress directory. */

Just above that line, add this wording:

define('WP_ALLOW_REPAIR',true);

Save your changes and leave your FTP program open for now. Open up your favorite web browser. Go to the following address for the rep

http://yourwebsitename.com/wp-admin/maint/repair.php

PHPMyAdmin

If the above methods don’t work, your next step is to head over to your database. This can be daunting if you aren’t sure exactly how databases work, but the steps are fairly simple. Even if you completely destroy the database, you should be able to just redownload from the old server and upload again. There really is no need to be afraid as long as you have your database backed up.