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 a 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 when 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:
- Search your code base for hard coded links with the old base TLD included and replace them with the new TLD.
- 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:
- Copy tracking codes from your Multisite installation to the new single site installation.
- 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.
Hi there, I have followed all the steps and while the website is working (I have uploaded everything to testing domain), it seems that I cannot access wp-admin. I tried disabling the plugins, removing htaccess file, uploading new wp-login file but with no luck. Any suggestions?
Hi Sandra,
I’m sorry to hear that! A common reason for not being able to access the /wp-admin/ page after switching is that the site address wasn’t updated from the old URL to the new URL if you were trying to make a subsite into the main site. Or maybe it was hardcoded somewhere. Since you can’t access your site, you’ll need to do a search and replace of your database for the old site address and then replace it with the new one.
There may be a mistake in the database tables that were updated. It could also be that you need to update your .htaccess file to include lines that aren’t related to Multisite and that are necessary to access your site that weren’t copied over.
Because I don’t have access to your site and hosting, it’s difficult for me to say for sure. If none of these suggestions are helpful, I would recommend getting a developer to look at it.
If you backed up your site and network beforehand, you can restore your site so you can regain access and try again.
Best of luck! I hope you’re able to fix it!
Kindly,
Jenni
Thank you very much for this clear steps to switch from a WooCommerce multisite configuration to a WooCommerce single site configuration!
Hi there,
I’m happy to hear that this article was helpful to you! Thanks for sharing.
Best,
Jenni
Thanks saved my day! 🙂
Hi there,
Awesome, I’m happy to hear that this article was helpful to you!
Best,
Jenni
Interest in knowing the opposite: how to migrate WooCommerce from a main ID 1 site to ID 6 site for instance.
Tried multiple methods and somehow the images always gone missing.
Hi Alex,
If the images consistently go missing every time you try, then it’s likely the image links need to be updated from the old site address to the new one. You can use the Search and Replace WordPress plugin to quickly help you with this part.
You can check out “Step #7: Search and Replace Image Links in the Database” in this article for guidance.
Best wishes,
Jenni
I followed your instructions but is says database connection error – any advise please?
Hi there Firoz,
I’m so sorry to hear that! This error means the database is unable to communicate with the WordPress site. It typically happens when the wp-config.php file has incorrect database details. Try redoing step four, making sure that the database credentials have been updated correctly.
Good luck with the fix! Feel free to contact us if you’d like us to help you make the changes you need.
Cheers,
Jenni McKinnon
Hi there. This guide is bү far tһe most accurate read սⲣ I had гead tһe past weеk!
Keep publishing gօod write up like this one and I’ll ƅe back for more!
#StaySafe аnd I’m sharing thіs article on social media гight now.
Hi there,
I’m glad you liked it. Thank you and I hope you stay safe and well, too!
Best wishes
hello, is this similar to wp multisite and make the main website as a single site instead? what will happen to other websites if you have 2 or more sub-sites? Thank you.
Regards,
Ann
Hi Ann,
It’s similar to Multisite, yes. WooCommerce relies on WordPress or Multisite if you have it installed. Once your switch from Multisite or WooCommerce Multisite, at the end of the process, you’ll lose your content from the other subsites. That’s why it’s suggested here to create backups before you continue.
You can also choose to copy the subsite or main site instead, then migrate to a new server. That way, you can keep both the rest of the network as well as the newly migrated site. Many popular backup plugins help with this process.
Best wishes,
Jenni McKinnon