How to properly migrate a WordPress site


WordPress store URLs of the pages, articles, media and all other content in database as absolute paths.

This mean that you need to update URLs when the site address changes, the simple database copy may lead to errors or increased load time, because of increased number of load requests.

For a proper migration, you have to copy the files to the new location and migrate the database. To copy the files you can use the hosting panel File Manager (if available), FTP or SSH. For the database migration – check the instructions bellow.


This article cover the following situations:

  • Migration to a new domain;
  • Migration of the site form some dev location to a production one;
  • Switching the site from HTTP to HTTPS;
  • Switching the site from www to non-www, or from non-www to www;
  • Sometime it may be required for migration from one hosting environment to another, even if the domain is not changed (but the location path changes).

Database migration

You can find a lot of instructions on the internet that will say that it is just enough to change two URLs in options table in database, hardcode new site URL in wp-config.php or make some redirections via .htaccess file.

It is not!

The only one good solution is to update all the links in the database and in site files (if you use somewhere absolute URLs).

Also, you can’t just replace the URLs in the database, because some components store the URLs as PHP serialized strings and that will broke the site.

Before migration, make a complete site backup (database and files), disable any security and caching options of the site, clear any existing temporary or cache files.

The most efficient and easy for migration is to use a special plugin for migration. There are a lot of them. The one I recommend is WP Migrate DB. It allows you to define the migration scenario, then exports the database with applied changes.


  1. Install and activate the plugin, go to Tools, Migrate DB.
  2. Configure the “Find” and “Replace” rules (Enumerate all the combinations you have in the database, replace all of them with a single valid new domain URL).
  3. Click on “Export”, save the updated database.
  4. Go to Database management tool (ie: PHPMyAdmin), delete all the tables related for WordPress (be aware if you have some tables not related to WordPress in the same database!).
  5. Import the migrated database.
  6. Check the WordPress theme for any absolute URLs that require update.


WordPress is a great CMS, simple to use and administrate, but a migration should be done correctly to avoid problems.

If you have some questions – don’t hesitate to ask me. If you don’t have time to spent on that – hire me as freelancer!
Last update: 2017/01/30

Leave a Reply

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