Get a free advice now!

    Pick the topic

    Developer OutsourcingWeb developingApp developingDigital MarketingeCommerce systemseEntertainment systems

    Thank you for your message. It has been sent.

    Tags

    How to migrate a WP multisite to a single WordPress site

    How to migrate a WP multisite to a single WordPress site

    We have a multisite WordPress website with a lot of subsites. MS installation uses subfolders as url format.

    Examples:

    example.com/subsite1

    example.com/subsite2

    example.com/subsite3

    We decided:

    • to move each subsite to a standalone WordPress installation without a multisite
    • each site will be hosted on separate accounts
    • URLs will be configured in: SUBDOMAIN_INSTALL format

    The new page urls will use subdomains, examples:

    subsite1.example.com

    subsite2.example.com

    subsite3.example.com

    In this tutorial, we will describe step by step how to migrate the WordPress website. The preferred tool is WP CLI, which is fast and easy to use.

    Copying all files

    The first step is to copy all files to the new hosting:

    • WordPress core files
    • theme files
    • plugin files
    • uploads (ex: /wp-content/uploads/sites/3/ → /wp-content/uploads/ )
    • add the default WP htaccess

    Multisite Database

    The WP MS database uses a number prefix for each subsite. We need to export all tables with a particular prefix to create a new standalone installation. To get the list of all sites, we can use the following WP CLI command:

    wp site list

    Here is the output:

    +---------+------------------------------------+---------------------+---------------------+
    | blog_id | url                                | last_updated        | registered          |
    +---------+------------------------------------+---------------------+---------------------+
    | 1       | https://example.com/subsite1/      | 2021-05-21 14:21:13 | 2020-11-18 13:04:22 |
    | 3       | https://example.com/subsite2/      | 2022-06-15 22:51:54 | 2020-11-18 13:46:45 |
    | 4       | https://example.com/subsite3/      | 2022-04-28 08:56:40 | 2020-11-19 11:03:20 |
    | 5       | https://example.com/subsite4/      | 2022-04-25 13:29:04 | 2022-04-05 11:29:41 |
    +---------+------------------------------------+---------------------+---------------------+

    The first column – blog_id – will tell us which tables should be exported. The site example.com/subsite2 has blog_id set to 3, so we will look for tables that start with the wp_3_ prefix.

    3 migration steps

    There are only three migration steps that need to be completed to move a multisite website to a single installation:

    • import all tables with a particular subsite prefix
    • change table_prefix in wp-config.php
    • change domains’ urls in the database (replace old urls with new ones)

    Export SQL tables

    We already know that MYSQL tables that start with the wp_3_ prefix include content of our website. Exporting can be performed using phpMyAdmin or any other MYSQL client (HeidiSQL or Workbench).

    An even easier solution is to use the WP CLI command:

    wp db export --tables=$(wp db tables --url=example.com/subsite2/ --format=csv --skip-plugins --skip-themes --allow-root) subsite2.sql --allow-root

    The result of running this command will be a subsite2.sql file created in the current directory. It will contain all SQL created tables’ definitions and data inserts.

    Change the DB prefix

    The Wp-config.php file placed in the main WordPress directory is responsible for site configuration. The default value:

    $table_prefix = 'wp_';

    should be replaced with the new prefix:

    $table_prefix = 'wp_3_';

    Make sure to set up a table prefix that exists on your old multisite.

    Import tables

    Use subsite2.sql file to import data to the newly created database. Use your favorite DB Client, or WP CLI command presented here:

    wp db import subsite2.sql

    WP search-replace urls

    Replacing database urls is a standard procedure for migrating WordPress sites. Direct changes in the database are not recommended: strings can be serialized and direct changes can corrupt the database. To replace urls (domains) in the database, there are a couple of recommended tools:

    Here is an example of using the command-line interface for WordPress (WP CLI) to replace DB urls:

    wp search-replace 'example.com/subsite2' 'subsite2.example.com' --allow-root --all-tables

    Summary

    That’s it. Only these 3 steps are needed to move your multisite subsite to a single WordPress installation. As a result, your old site example.com/subsite2 will now be working smoothly on the domain: subsite2.example.com .

    Interested in enhancing your site’s performance? Learn more by exploring our article on the async plugin WordPress.

    Subscribe to our newsletter to stay up-to-date with the latest tips and guidelines.

    Comments
    0 response

    Add comment

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

    Popular news

    Digital marketing without third-party cookies – new rules
    • Technology
    • Trends

    Digital marketing without third-party cookies – new rules

    February 21, 2024 by createIT
    eCommerce healthcheck
    • Services
    • Trends

    eCommerce healthcheck

    January 24, 2024 by createIT
    Live Visitor Count in WooCommerce with SSE
    • Dev Tips and Tricks

    Live Visitor Count in WooCommerce with SSE

    December 12, 2023 by createIT
    Calculate shipping costs programmatically in WooCommerce
    • Dev Tips and Tricks

    Calculate shipping costs programmatically in WooCommerce

    December 11, 2023 by createIT
    Designing a cookie consent modal certified by TCF IAB
    • Dev Tips and Tricks

    Designing a cookie consent modal certified by TCF IAB

    December 7, 2023 by createIT
    Understanding the IAB’s Global Vendor List (GVL)
    • Dev Tips and Tricks

    Understanding the IAB’s Global Vendor List (GVL)

    December 6, 2023 by createIT
    Effortlessly transform JSON data into a clear schema
    • Uncategorized

    Effortlessly transform JSON data into a clear schema

    December 5, 2023 by createIT

    Support – Tips and Tricks
    All tips in one place, and the database keeps growing. Stay up to date and optimize your work!

    Contact us