How to transfer a WordPress website from one domain or host to another.

First stage.

First, backup. If something goes wrong, you must have a fall-back plan.

For the sake of this guide, we will identify the two locations where your website currently is as the old website” while the destination will be known as the “new website”.

To back up your old website, go to the old website’s file manager, in the root directory, zip and download the wp-config.php file. Download the file.

Go to the wp-content directory, zip and back up either the entire folder (wp-content) or each folder found in the wp-content directory. When you zip them, download them locally.

Next, Identify your old website’s database (DB) by viewing the Database name in the wp-config.php file in the root folder of your old website. Check the ‘define( ‘DB_NAME’, ‘xxxxxxx_xxx’ );’ line for this data.

Also, take note of your website’s DB table prefix. It could be different from the default one. If it’s changed, and you do not use the correct one, the migration might be unsuccessful. So, take note of the DB table prefix. It is usually found written like this ‘ $table_prefix = ‘xxxxx_’; ‘ with a trailing underscore. Copy and save it somewhere.

Now go to your old website’s hosting panel and access your old website’s DB via phpmyadmin.

Next, view the DB, locate and identify your website’s domain as it is, in the DB. In your DB, locate the ‘wp_options’ table (or if your table prefix is different from the default one i.e. ‘xxxx_options’), and look for the option_name data, site_url. The value beside it under the option_value should be your website’s URL. Save this URL somewhere as ‘oldurl’. Save it exactly as it is. It is very important as you will need it later. (You can double-click the database field and copy the entire data in that field).

Goto the Export Tab on your myphpadmin menu. Click Go to download the entire database. Save this database file locally.

If you completed all the previously listed steps above, then you have successfully backed up your old website.

Now it’s time to move your old website to its new location.

On your new website’s location, look for any wizard that will aid you in installing WordPress seamlessly. If your host does not have any wizard for that, you will have to install WordPress manually.

When you install WordPress successfully, ensure the new website is loading from the front end. Access it via your web browser, a private tab and a new or different browser. When you are sure the new website is loading, move to the next step.

Second stage.

First, go to the File Manager of your new website. Zip and backup the wp-config.php file and the wp-content directory. However, do not download it. You won’t need it as this backup is simply to aid you restart the entire process of the second stage only, if something goes wrong.

Open the new website’s wp-config.php file. View the table prefix and ensure it matches that of the old one.

Replace the new website’s wp-content directory with the data from the old website’s wp-content directory.

Visit your new website’s database via the phpmyadmin panel.

View the newly created DB, locate and identify your new website’s domain as it is, in the new DB. In your new DB, locate the ‘wp_options’ table (or if your table prefix is different from the default one i.e. ‘xxxx_options’), and look for the option_name data, site_url. The value beside it under the option_value should be your new website’s URL. Save this URL somewhere as ‘newurl’. Save it exactly as it is. It is very important as you will need it later. (You can double-click the database field and copy the entire data in that field).

Import the old DB. Click the Import tab from the menu.

Click Browse, and select the old DB file from your PC or Mac. Click Go to start the Import process.

Next, on your phpmyadmin tabs/panel, use the SQL tab to run SQL commands. Ensure you select your new DB first.

Copy and paste the following command block onto the SQL Command line:

Replace the ‘oldurl.com’ data anywhere you see it, with your previously saved data for ‘oldurl’.

Replace the ‘newurl.com’ data anywhere you see it, with your previously saved data for ‘newurl’.

Run the command.

Now, if the command executes successfully, visit your website’s new URL from your web browser. If everything goes well, your old website should display without errors.