How to create a WordPress Multisite network

A WordPress Multisite network lets one WordPress installation host several related sites from the same codebase and database. Creating the network changes routing, database tables, and administration screens, so the conversion should start from a known backup and end with a real subsite request.

WP-CLI can convert an existing single-site installation into a subdirectory network without using the dashboard setup screen. The conversion adds network tables and Multisite constants to wp-config.php, while the web server still needs rewrite rules so paths such as /team/ reach the correct site.

Examples use an Apache-hosted site at http://www.example.com with WordPress already installed and WP-CLI working in the document root. Subdomain networks require wildcard DNS and the --subdomains option; Nginx sites need matching server-block rewrite rules instead of .htaccess.

Steps to create a WordPress Multisite network with WP-CLI:

  1. Open a terminal in the WordPress document root and confirm the site URL before changing network mode.
    $ cd /var/www/html
    $ wp option get home
    http://www.example.com

    Run the remaining wp commands from the directory that contains the active wp-config.php file.

  2. Create a current backup of the database and document root.

    Multisite conversion changes database tables and wp-config.php. Keep a rollback copy of the database, uploads, plugins, themes, and existing server rewrite file before continuing.

  3. Deactivate active plugins before converting the site.
    $ wp plugin deactivate --all
    Plugin 'google-site-kit' deactivated.
    Success: Deactivated 1 of 1 plugins.

    Record which plugins were active before the conversion so only the intended plugins are reactivated after the network is verified.

  4. Convert the site into a subdirectory Multisite network.
    $ wp core multisite-convert --title="Example Network"
    Set up multisite database tables.
    Added multisite constants to 'wp-config.php'.
    Success: Network installed. Don't forget to set up rewrite rules (and a .htaccess file, if using Apache).

    For a subdomain network, add --subdomains only after wildcard DNS and virtual-host routing already point child hostnames such as team.example.com to this WordPress installation.

  5. Confirm that Multisite is enabled in wp-config.php.
    $ wp config get MULTISITE
    1
  6. Replace the existing WordPress rewrite block in .htaccess with the subdirectory Multisite rules.
    # BEGIN WordPress Multisite
    RewriteEngine On
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    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 Multisite

    Use the rule block that matches the chosen network type. This rewrite block is for subdirectory networks on Apache.

  7. Create a test subsite in the new network.
    $ wp site create --slug=team --title="Team Site" --email=admin@example.com
    Success: Site 2 created: http://www.example.com/team/

    Use an administrator email address that should receive network-site notifications for the new site.

  8. List the network sites and confirm the new subsite URL appears.
    $ wp site list --fields=blog_id,url --format=table
    blog_id	url
    1	http://www.example.com/
    2	http://www.example.com/team/
  9. Request the test subsite through the web server rewrite layer.
    $ curl -I http://www.example.com/team/
    HTTP/1.1 200 OK
    Server: Apache/2.4.67 (Debian)
    Link: <http://www.example.com/team/wp-json/>; rel="https://api.w.org/"
    Content-Type: text/html; charset=UTF-8

    A 200 OK response for the subsite path confirms that WordPress registered the site and Apache routed the subdirectory URL into the Multisite front controller.
    Tool: HTTP Header Checker

  10. Reactivate only the plugins that should run after the network conversion.
    $ wp plugin activate google-site-kit
    Plugin 'google-site-kit' activated.
    Success: Activated 1 of 1 plugins.

    Use wp plugin activate <plugin-slug> for a single-site activation and wp plugin activate <plugin-slug> --network only when the plugin should run across every site in the network.