Migrate a WordPress from MultiSite to Simple

Occasionally, we need to take one of the sites from a WordPress Multisite to a normal site, a simple installation. The process is not automatic, although there are some tools that allow it.

Tools like Duplicator Pro allow you to make a copy of the entire site and when you recover it, you can choose only one of them to restore.

But in most cases, you do not have external tools, so you can perform a step-by-step migration process.

Preparation

The first thing we need to know is the ID of the site we are going to want to separate. This can be achieved in the list of WordPress Multisite Sites. In this example, we will use ID number 2.

The database

If we access a panel of the style to phpMyAdmin, we must export the tables that begin with the prefix that we have, followed by 2_. The tables will have an appearance of the style a wp_2_comments.

In addition to these tables we must select the tables that affect the users, which are wp_users and wp_usersmeta.

When we have the file . SQL will have to replace all the names of the tables. The idea is to remove the 2_ one from all sites. As this can affect many things, we will make a substitution of wp_2_ by wp_.

Now that we have the SQL file, we must import it into the new site. We must have a database created but not the site or WordPress installed, that is, it must be empty.

The files

For the new site, we can download the latest version of WordPress and upload it to the server.

Now that we have the base files, we will have to copy from the source site some things from the /wp-content/.

On the one hand, we must copy the active plugins, on the other the themes that we are using and finally the files.

Of the uploaded files, we will have to look for the folder /wp-content/uploads/sites/2/ (where 2 would be the ID) and we will copy it to /wp-content/uploads/.

The configuration

Now that we have the database to the point, and the files where it touches, we have to make some modifications to the wp-config.php.

It is best to copy the original file from the database and make changes to it. As usual, we have to change the connection data to the database: DB_NAME, DB_USER and DB_PASSWORD.

As a next point, you have to undo all the configuration of the WordPress Multisite.

All code, which should be similar to this:

define( 'WP_ALLOW_MULTISITE', true );
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'example.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

This must be replaced by

define( 'WP_ALLOW_MULTISITE', false );

In addition, to correct possible internal links that are not correct, we will set the addresses by effect, adding to the WP-Config the URL of our new site:

define( 'WP_SITEURL', 'https://www.example.com' );
define( 'WP_HOME', 'https://www.example.com' );

We will also have to recover the simple initial configuration of the .htaccess (or the configuration of the nginx).

By default we will find something like a:

# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*.php)$ $2 [L]
RewriteRule . index.php [L]
# END WordPress

And we will replace it with the initial code:

# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

Accessing

At this time, if everything has gone well, the site should work properly to access the dashboard. Although there are a couple of configurations left.

Replacement of the media

Before finishing, we must replace the URLs of the images and Media in general with the new addresses. For this, we can use the WP-CLI replacement system, or we can install a replacement plugin.

The substitution must be:

/uploads/sites/2/

Where the number 2 will be that of the original site ID. We will replace it simply with:

/uploads/

In the same way, we will have to replace the entire site. For example, replacing the old address:

//old.example.com/es/

For the new direction.

//www.example.com/

Permanent links

As a last step, we will go to the Permalink Settings and click on Save.

And with this, we would end the migration from a MultiSite site to a Simple site.


About this document

This document is regulated by the EUPL v1.2 license, published in WP SysAdmin and created by Javier Casares. Please, if you use this content in your website, your presentation or any material you distribute, remember to mention this site or its author, and having to put the material you create under EUPL license.

1 thought on “Migrate a WordPress from MultiSite to Simple”

Comments are closed.