How to Set Up WordPress Multisite

Quick Summary

  • Add WP_ALLOW_MULTISITE to wp-config.php, deactivate all plugins, then run Tools > Network Setup and pick sub-domains or sub-directories, which you can't change later.
  • Paste the generated constants into wp-config.php and the generated rewrite rules into .htaccess; on Nginx, the rules go in the server block instead.
  • Converting resets the main site's permalink structure, so check Settings > Permalinks afterwards, and use separate installs for sites with different owners or setups.

WordPress Multisite runs a network of sites from one WordPress installation. To turn it on, add define( 'WP_ALLOW_MULTISITE', true ); to wp-config.php, deactivate all plugins, open Tools > Network Setup and click Install. WordPress then gives you a block of constants for wp-config.php and rewrite rules for .htaccess. Add both, log in again, and the network is ready. The steps below follow the Network Setup screen in WordPress 7.1.

Before you start

  • Back up the database and the files. You will edit wp-config.php and .htaccess, and the setup adds the network tables to the database.
  • Check that pretty permalinks work on the site as it is now, and note the structure under Settings > Permalinks. The conversion resets it (step 5).
  • Deactivate every plugin. Network Setup won’t run while any plugin is active. You can reactivate them once the network exists.
  • Choose between sub-domains (site1.example.com) and sub-directories (example.com/site1). The setup screen says it plainly: you cannot change this later. The comparison further down helps you pick.

Step 1: Allow Multisite in wp-config.php

Open wp-config.php in the WordPress root folder and add these lines above the comment /* That's all, stop editing! Happy publishing. */:

PHP
/* Multisite */
define( 'WP_ALLOW_MULTISITE', true );

Older wp-config.php files end that comment with Happy blogging instead; the spot is the same. If your file has neither comment, add the lines above the line that loads wp-settings.php. Constants defined after that line come too late.

Step 2: Run Network Setup

Reload the dashboard. A new Network Setup item appears under Tools. On that screen, choose sub-domains or sub-directories, check the Network Title and Network Admin Email, and click Install.

WordPress doesn’t always offer both address types. From its setup code:

  • Sub-domains are not offered when the site address is localhost, an IP address, or includes a path (WordPress installed at example.com/wp/, for example).
  • Sub-directories are not offered when the site has published posts older than a month, because of conflicts with the main site’s existing permalinks. Defining ALLOW_SUBDIRECTORY_INSTALL as true lifts this check, but the main site’s posts then get a /blog/ prefix (see step 5), which changes their URLs.
  • For a sub-domain network, WordPress requests a random sub-domain of your domain. If that fails, it warns that wildcard DNS may not be configured. The network is still created, but sub-domain sites may not be reachable until DNS has a wildcard (*) record pointing at your server.

Step 3: Add the generated constants to wp-config.php

The next screen shows the code for your site. For a sub-directory network on example.com it looks like this:

PHP
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', false );
define( 'DOMAIN_CURRENT_SITE', 'example.com' );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );

Copy the block from your own screen, not from this post, and paste it above the same stop editing comment. Keep the WP_ALLOW_MULTISITE line: while it is there, the network dashboard keeps a copy of this setup code for reference.

  • MULTISITE switches the network on.
  • SUBDOMAIN_INSTALL is true for a sub-domain network and false for sub-directories.
  • DOMAIN_CURRENT_SITE and PATH_CURRENT_SITE are the domain and path of the main site (/ when WordPress sits in the web root).
  • SITE_ID_CURRENT_SITE is the network’s ID and BLOG_ID_CURRENT_SITE is the main site’s ID. Both are 1 on a new network.

If wp-config.php is missing any of the authentication keys and salts, the screen lists those too. Add them as well.

Step 4: Add the rewrite rules

Apache: .htaccess

On Apache, Network Setup also generates rewrite rules. Put them in the .htaccess file in the WordPress root, replacing the existing lines between # BEGIN WordPress and # END WordPress. For a sub-directory network in the web root, WordPress 7.1 generates:

Code
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]
  • The ([_0-9a-zA-Z-]+/)? part matches a site’s path, such as site1/, so example.com/site1/wp-admin/ is served by the same WordPress files. The sub-domain version of these rules doesn’t have it, because the site is identified by its host name.
  • Once Multisite is on, WordPress no longer rewrites .htaccess when you save permalinks, so the rules stay exactly as you pasted them.
  • Keep any other rules, such as a www to HTTPS redirect, outside the WordPress markers.

Nginx

Nginx doesn’t read .htaccess files. On Nginx, Network Setup shows no rules at all, only a link to the Nginx page in the WordPress documentation. For a sub-directory network, that page gives these rules for the site’s server block:

Code
if (!-e $request_filename) {
    rewrite /wp-admin$ $scheme://$host$request_uri/ permanent;
    rewrite ^(/[^/]+)?(/wp-.*) $2 last;
    rewrite ^(/[^/]+)?(/.*\.php) $2 last;
}

location / {
    try_files $uri $uri/ /index.php?$args ;
}

A sub-domain network needs only the usual try_files line, plus a server_name that accepts every sub-domain, such as server_name example.com *.example.com;. Test the configuration with nginx -t before you reload Nginx. On IIS, Network Setup generates web.config rules instead.

After you save both files, WordPress asks you to log in again. If the login doesn’t stick, clear the browser’s cookies for the site.

Then open Settings > Permalinks on the main site. When WordPress converts a single site, it resets the main site’s permalink structure to /%year%/%monthnum%/%day%/%postname%/. On a sub-directory network it adds a /blog prefix to that structure, and the Permalinks screen keeps the prefix. On a sub-domain network you can set your old structure back, so existing post URLs keep working.

Managing the network

  • The network has its own dashboard under My Sites > Network Admin. Add sites from Sites > Add Site.
  • Plugins and themes are installed once, from Network Admin. A theme must be Network Enabled before sites can use it. A plugin can be Network Activated for every site, or activated per site.
  • Site administrators can’t install or update plugins and themes; only the network’s Super Admin can. Under Network Admin > Settings, Enable administration menus decides whether site admins see the Plugins menu at all.
  • To give a site its own domain, edit its Site Address (URL) under Network Admin > Sites. Domain mapping has been built into WordPress since 4.5, so no plugin is needed.
  • The Network Setup screen moves to Network Admin > Settings > Network Setup and shows the configuration code again, as long as WP_ALLOW_MULTISITE is still defined.

Setting it up with WP-CLI

With shell access, WP-CLI does steps 1 to 3 in one command. It creates the network tables and adds the constants to wp-config.php:

Shell
wp core multisite-convert --title="My Network"

Add --subdomains for a sub-domain network. The rewrite rules are still up to you: add them to .htaccess or the Nginx configuration as in step 4.

Sub-domains or sub-directories?

  • Sub-directories (example.com/site1) need no DNS changes and share the main site’s SSL certificate. On an existing site they are usually not available (see step 2), and the main site’s posts move under /blog/.
  • Sub-domains (site1.example.com) need a wildcard DNS record and, for HTTPS, a certificate that covers every sub-domain, usually a wildcard certificate for *.example.com. WordPress must be installed in the web root.

When not to use Multisite

Multisite suits a group of sites that one person or team runs together, such as a company’s regional sites or a network of similar blogs. It is the wrong tool when:

  • The sites belong to different clients or owners. One Super Admin controls plugins, themes and updates for everyone. Site admins also lose the unfiltered_html capability, so they can’t add scripts or iframes to their content.
  • The sites need different setups. All sites share one database, one server, one PHP version and one copy of each plugin and theme. An update to a plugin applies to every site that uses it.
  • You want the sites to share content. Each site has its own posts, pages and settings. The WordPress documentation says Multisite may not be the best solution for sites that are strongly interconnected or share data.

In those cases, separate WordPress installs are usually the better fit. The official Before You Create A Network page covers the requirements in more detail.

Share on X (opens in a new tab) Share on LinkedIn (opens in a new tab) Share on Facebook (opens in a new tab)

ChatGPT (opens in a new tab) Claude (opens in a new tab) Gemini (opens in a new tab) Perplexity (opens in a new tab) Grok (opens in a new tab)

More Insights

See More