To switch or migrate WordPress Multisite to single site is tricky. Add WooCommerce in the mix and it’s a bigger feat. That’s also exactly what I needed to do.

Throughout the process, I referenced an article from Delicious Brains and one from WPMU DEV. But, I found that they were both incomplete for my purposes since they didn’t also cover WooCommerce.

The requirements for this move was to make the secondary domain (i.e. site ID 2), the main single domain, which is technically more challenging than making the base domain (i.e. site ID 1) the one single domain.

This post details my experience with moving a live site from a WordPress Multisite setup with WooCommerce, and two top level domains (TLDs) to one single TLD. 

Getting Started

Before you get started, it’s crucial that you back up your entire site, including all WordPress and WooCommerce files, and database tables. You should also place your site into maintenance mode.

If something goes awry and errors pop up, you can quickly restore your site from your backup.

If you don’t have an automated backup system, manually create a backup.

Hosts such as WP Engine offer daily backups of the entire codebase and database. If you do not know how to backup your website, contact your host for support.

At the very least, you should have backup of your database and “uploads” folder since the “themes,” and “plugins” folder will not be touched.

You should also put your site in maintenance mode so no one can access it which you migrate WordPress Multisite to single site including your WooCommerce store.

This prevents users from temporarily using your site while you’re making crucial changes that could cause them to see errors unexpectedly.

There are plenty of free WordPress maintenance mode plugins and WP Maintenance Mode is an excellent option.

Now that this is all sorted, you can go ahead and start making the switch.

Step #1: Download the Site’s Database

The WooCommerce Multisite (Multi-Store) setup duplicates a set of tables for each site.  Since our goal is to extract only one of the sites from the ones that exist, we must export the tables that are associated to that site.

In my case, site ID 2, plus the user tables.

Using phpMyAdmin, click on your site’s database, and click Export.

Then, you need to keep all of the tables checked. That includes the ID of your site.

In my case, that’s site ID 2, which has this in its listed name: _2_.

Then, unselect all other tables excluding “wp_users” and “wp_usermeta” such as in the image below.

Keep all other settings as is, scroll to the bottom of the page, and click Go.

Your database should download locally, which could take up to a minute depending on the database size.

Step #2 : Edit the Database Table Names

In this step, you must rename the database tables from wp_2_ to wp_ since they are going to be the main tables for the site. This is as opposed to the secondary tables for an additional site.

Once the database has fully downloaded, open the SQL file in a text editor and do a search and replace from wp_2_ to wp_.

This should replace the database table names only and nothing else within the file text.

Save the file and close the text editor.

Step #3: Import the Modified Database

Now that you have the “new” modified database for the single site, create a new database in which to import the tables.

Create a new database in cPanel, or your host’s admin panel, and import the tables via phpMyAdmin by selecting the new table. Then, click Import.

Please note: If you’re using a Multisite subdomain or subfolder structure, then you will want to change the URL values in the database rows “siteurl” and “home” in the table “wp_options,” to the new single site URL.

Step #4: Remove WooCommerce Multisite Configuration in wp-config.php

In this step, we will be removing the Multisite definitions and changing the database configuration to the new one we just imported in the previous step.

Find your wp-config.php file in the root of the website and open it in a text editor.

First, switch the database table to the new table and user that was created for that table:

define('DB_NAME', 'new_table_name');
define('DB_USER', 'new_user_name');
define('DB_PASSWORD', 'new_user_password');

Next scroll down and find the following code, which is used to setup the Multisite:

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

Delete it, and replace it with the following code:

define( 'WP_ALLOW_MULTISITE', false );

Save the wp-config.php file and close it.

Step #5: Edit Your .htaccess File

The .htaccess file resides in the root folder of your website.  Open it in a text editor and delete the following code:

# 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

Now add the following code instead:

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

Save and close the .htaccess file.

Step #6: Copy the Multisite Images to the Single Site

For this step, you need a copy of the full Multisite “uploads” folder found at /wp-content/uploads/.

Within that folder, you will find another folder call “sites” and there, you will find a number corresponding to the site ID, and an “uploads” folder within it such as in this example: /wp-content/uploads/sites/2/uploads/.

Now, move the specific site uploads folder so it’s the main uploads folder since you’re going to do away with all other sites and their images.

I suggest you download a local copy of the /wp-content/uploads/ folder from a website backup you have. Then via FTP, simply copy the /wp-content/uploads/sites/2/uploads/ folder to /wp-content/uploads/, replacing all of its contents and deleting the “sites” folder in the process.

Step #7: Search and Replace Image Links in the Database

At this point, you should be able to log into your “new” single site without any issues.

You will notice that you now only have a single site install and the Multisite Network has been removed.

Once logged in, I suggest installing the Search and Replace plugin so you can replace any image links that are broken due to step six.

Activate the plugin, then go to Tools > Search & Replace and click on the Search & Replace tab.

You want to search for all instances of “/uploads/sites/2/” and replace them with “/uploads/” and don’t forget to replace “2” with the actual site ID for your case.

It’s also a good idea to select Dry Run the first time you search and replace. That way, you can make sure the process was done correctly.

Once you are certain all fields are set correctly, uncheck Dry Run and select Save changes to Database.

It may also be important to note that there’s another step you may want to take if you are seeing broken images, or your website is not loading correctly. You can search and replace the old main domain on the Multisite with the new single domain.

Step #8: Save Permalinks

The final step, which is simple but crucial, is to go to Settings > Permalinks and click Save.

This ensures all of your links will work properly on your site.

Noteworthy Tips to Migrate WordPress Multisite to Single Site

Once you have completed the steps above, you might still be seeing some weird behavior on your website which could be due to many different factors.

Here are some areas to check for errors:

  1. Search your code base for hard coded links with the old base TLD included, and replace them with the new TLD.
  2. Disable plugins that might not be relevant anymore since your site is no longer a Multisite step.

Other tasks which you might need to consider:

  1. Copy tracking codes from your Multisite installation to the new single site installation.
  2. Redirect removed old TLD to the new single TLD for SEO purposes.

Conclusion

Switching a WooCommerce Multisite to a single site is by no means a trivial task, but following the steps above should do the trick.

The complexity of your setup could cause unforeseen issues so if you’re unsure about any of the steps, let our verified expert WooCommerce developers help you successfully make the switch for you while reducing the downtime of your website, and keeping your site safely backed up so nothing is lost.

What are your plans for your WooCommerce Multisite? Were you able to successfully migrate WordPress Multisite to single site including your WooCommerce store? Did you run into any issues you need help resolving? Share your experience in the comments below.

Leave a Reply

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