How to transfer a Wordpress site from one domain to another?
Random | 02 Aug 2016
Tags: database, wordpress, migration
Other than uploading your wordpress sites to the new domain, you will need to do some changes in your database. Therefore, when you want to move the wordpress website to a new domain, you will find out that existing database records are still pointing at the old domain. So how do we properly migrate our wordpress site to the new domain name?
I have seen a lot of developers going straight to the database and updating records to a new domain. Some just write update queries to change the domain. Usually they end up with corrupt wordpress site - which may not be functioning. If you are lucky the site may be still working but you may experience other issues with the website later on.
So what makes changing the wordpress domain so complex? And is it really such a big deal? Not really - the answer lies in serialised strings in the database. Because you cannot manually modify serialized strings, you will need a script to do this for you.
After searching I found out some useful script that will help you replace all occurrences of the old domain to the new one.
Follow these steps for proper migration of your wordpress site:
- Before starting I prefer to backup the existing database. You can do this from the control panel, or phpmyadmin / other database access interfaces - if something goes wrong you can always restore your wordpress site database.
- Download the script from this link:
[download-attachment id="323" title="Search-Replace-DB-master.zip"]
- Extract the contents to where you have uploaded your website.
- Access the url which will lead you to installed script location
- Carefully choose the old site name in the strings to replace, including http:// and www in case it was used in the old wordpress configuration. For example: http://www.[oldsitename].com
- Submit the new site name with the full url : http://www.[newsitename].com
- Submit the database credentials
- Dry run the script to check what changes will be made after the script is running
(You can click on specific change to see the differences which will be made in the database script)
- Click "Update" and confirm to update the database record
- Enjoy your properly migrated wordpress site.