Moving a WordPress Site to a New Domain

Moving a WordPress Site to a New Domain

As someone who tests sites and builds client sites within test environments before going live I spend a considerable amount of time moving WordPress sites to a new domain. It can go extremely well or extremely wrong depending on if you follow the right procedure. Below is how I do the move, it might not be for everyone and there are indeed other methods but this works and only requires access to phpMyAdmin and an FTP client such as Filezilla.

In advance of doing the following please make sure that you backup the original WordPress site to ensure that if something goes wrong you can restore it.

Next install WordPress onto the new server, making sure that the version matches the version you’re migrating from. If it doesn’t either upgrade the source server, or downgrade the version you’re installing on the destination server.

Add the two servers to your FTP client (making sure to mark one as old and one as new!)

Then go to cpanel on your old host and access phpMyAdmin (normally under the Databases listings).

Moving WordPress Site to a new Domain Image 1

Select your wordpress database (in the example below it’s labeled adminboy_wp491) and click on Export on right hand tabs, then Go (SQL should be selected automatically in the drop down, if not select that before selecting Go)

Moving a WordPress Site to New domain screen 2

On the new server open phpMyAdmin and select Import. Choose the SQL file that you exported above and ‘Go’

Moving WordPress to a new server

Select the table that says options from your imported list and update the first two fields to reflect your new domain name.

phpmyadminchange

Open your FTP client and download from the old server the folders wp-content/uploads, wp-content/themes/YOURTHEME (if it is a child theme then copy the parent theme too), wp-content/plugins (you can just install them again either but sometimes this rules out a plugin being forgotten). Also download the file wp-config.php from the root of the installation.

transfer

Open the file wp-config.php that you downloaded and add the following line:    define(‘RELOCATE’, true);

This line makes sure you don’t get the common error of getting redirected to the old site when you try to go into the administration area. Once the site is setup and running you can delete this line again.

wpconfig2

 

Open your FTP client and upload to the new server the files you downloaded, overwriting files that have the same name.

And there you go, when you now browse to the new site you’ll see (hopefully) the new site up and running. At this stage if you take the old site offline you’ll be able to see what (if any) absolute mappings you had in the old site. This can include absolute links to images and pages which need to be fixed. In addition sometimes you’ll get errors with page aliases, simplest thing here is to go into settings-permalinks and reselect the preferred permalink format. This usually fixes the issue.

 

Leave a Reply

Your email address will not be published. Required fields are marked *