New To Essentialplugin?
Save above 50% or More on Essential Plugins Bundle Plans..... Grab Now
00 Hours
00 Mins
00 Sec

WordPress Multisite Network Migration

What is WordPress Multisite?

A WordPress multisite network allows you to run and manage multiple WordPress sites from a single WordPress installation.

When you need the WordPress Multisite Network?
  1. A magazine website with different sections managed by different teams.
  2. A business website with sub-sites for different locations and branches.
  3. Government or non-profit websites can use WordPress multisite for different departments, locations, and regions.
  4. Your own network of blogs running on multiple subdomains.
  5. Schools and colleges allowing students to create their own blogs on school servers.
Exporting/Importing your WordPress Database

The first step to start a migration of your WordPress site is to move the contents from your current host to a new server.

The best option for it is to export the data directly through MYSQL commands. If you have SSH access to your servers you can use the command mysqldump to do this.

Export a SQL file from your database

mysqldump -uUSER -password DBNAME > export.sql

Import a SQL file to your database

MySQL –uUSER –pPASSWORD DBNAME < export.sql

Remember to change USER, PASSWORD, and DBNAME to the right values in your installation. If you have forgotten these credentials, open your wp-config.php file (when you have access to it) and you’ll find them there.

Transferring Files, Plugins, and Themes
  • These two statements tell WordPress to ignore the values in the database and use the home and site URL values that you specify in the wp-config.php
Updating URLs in Posts and Custom Fields

When you change the domain name, you need to update all the posts and custom fields that include the old URL with the URL of the new domain. When you insert a link or an image, WordPress will store it with its full path. All these absolute references have to be replaced when you’re moving to the new domain. Otherwise, all inline link and images still point to the previous domain, producing 404 errors.

To fix this, we can directly go to phpMyAdmin and access our WordPress database. Before doing anything, you should backup the database, using the export function we described before. Afterwards, you can apply the following SQL statements:

UPDATE wp_options SET option_value = REPLACE(option_value, ‘https://my-old-domain.com’, ‘https://new-domain.com’) WHERE option_value NOT LIKE ‘%{%’; UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, ‘https://my-old-domain.com’, ‘https://new-domain.com’) WHERE meta_value NOT LIKE ‘%{%’; UPDATE wp_posts SET guid = REPLACE(guid, ‘https://my-old-domain.com’, ‘https://new-domain.com’);

Once you have run each of these update statements, phpMyAdmin will tell you how many rows in your database were updated. Check that this number makes sense.

Note that I’ve excluded rows that have the character { in them as they would be part of serialized arrays. To replace URLs (or any other string) inside serialized arrays, go to the next section

Once you have your database ready, it is time to transfer the files stored in your old WordPress host to the new one. Basically, this means copying all the contents from the following folders:

  • wp-content/themes: here is where all your WordPress themes are located. Just copy all of the contents to this folder, unless you decide to switch to a new theme. In that case, you can ignore these files.
  • wp-content/plugins: here is where all your WordPress plugins are located. Again, copy all the contents to new host. Note that the plugin configurations are stored in your WordPress database, so after importing the SQL file from the previous steps, everything should work perfectly in your new host.
  • wp-content/uploads: here is where all the media files that appear in the Media Library are located. Note that the size of this folder may be huge when using a lot of images in your site.
  • WordPress Configuration after Migration
  • This part can be tricky too. Your database has lots of references to your old site. If you changed your domain name in a migration, trying to access your new WordPress site after importing your database file will result in several redirection problems. The reason for this is that your WordPress thinks that it is located on your old server with your old domain. To solve these wrong URL address problems, continue reading.
  • Telling WordPress that the Site’s Location Has Changed
  • If the URL you see there is not the URL of the new domain, WordPress will always redirect you to the URL you have there. In order to easily fix this issue, search for the following lines in your wp-config.phpfile (or add them to the end of that file) and put there your correct URL:
  • define(‘WP_HOME’, ‘https://my-domain.com’);
  • define(‘WP_SITEURL’, ‘https://my-domain.com’);