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 .

    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 – transform data into insight 
    • Trends

    Digital marketing – transform data into insight 

    November 24, 2023 by createIT
    A simple JavaScript typewriter effect tutorial
    • Dev Tips and Tricks

    A simple JavaScript typewriter effect tutorial

    November 22, 2023 by createIT
    WP-HistographAI: reviving history with AI on WordPress
    • Dev Tips and Tricks

    WP-HistographAI: reviving history with AI on WordPress

    November 21, 2023 by createIT
    Update Excel files on OneDrive with Node.js, MS Graph
    • Dev Tips and Tricks

    Update Excel files on OneDrive with Node.js, MS Graph

    November 20, 2023 by createIT
    Popup Visits Plugin: engage your visitors on their X visit!
    • Dev Tips and Tricks
    • Technology

    Popup Visits Plugin: engage your visitors on their X visit!

    November 17, 2023 by createIT
    The most popular eCommerce technologies among top players
    • Technology
    • Trends

    The most popular eCommerce technologies among top players

    October 26, 2023 by createIT
    BaseLinker: the tool, challenges and BaseLinker alternatives
    • Technology
    • Trends

    BaseLinker: the tool, challenges and BaseLinker alternatives

    October 25, 2023 by createIT
    The power of popups: why every WordPress site needs one
    • Technology
    • Trends

    The power of popups: why every WordPress site needs one

    October 24, 2023 by createIT
    AI pet Personality Quiz: revealing your pet’s unique traits
    • Dev Tips and Tricks
    • Technology

    AI pet Personality Quiz: revealing your pet’s unique traits

    October 23, 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