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.
$ 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.
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.
Related: How to back up a WordPress 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.
$ 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.
$ wp config get MULTISITE 1
# 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.
$ 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.
$ wp site list --fields=blog_id,url --format=table blog_id url 1 http://www.example.com/ 2 http://www.example.com/team/
$ 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
$ 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.