Skip to content

WordPress multisite: subdomains vs subdirectories, and how to choose

The multisite addressing model is fixed at network creation and changing it later is a migration. How WordPress routes a request to a site ID under each model, what wildcard DNS and wildcard TLS actually cost you, where subdirectory installs collide with page slugs, and how cookies and search signals differ.

WordPress asks one question at network creation that you cannot take back, and most people answer it in about four seconds. For the common case the right answer is subdirectories: one hostname, one certificate, no DNS work, and the sub-sites sit inside the parent domain’s existing reputation. Choose subdomains when the sites are meant to read as separate properties, when something else already needs per-site hostnames, or when individual sites are likely to move onto their own domains later. The part that is hard to reverse: the choice becomes the SUBDOMAIN_INSTALL constant in wp-config.php, and every site URL, every upload path, and every absolute link in your content is derived from it. Flipping that constant afterwards moves nothing — it only makes WordPress look for sites at addresses that were never created. Switching models on a live network is a migration with a redirect map, not a settings change.

What you’ll accomplish

  • Decide subdomain vs subdirectory from your actual DNS, TLS and content constraints instead of taste.
  • Understand precisely how WordPress turns an incoming request into a site ID under each model.
  • Stand the network up with the right constants and rewrite rules on the first attempt.
  • Get wildcard DNS and a wildcard certificate in place before the first sub-site exists, if you go the subdomain route.
  • Recognise the cases where two separate WordPress installs beat one network.

Prerequisites

  • Written against WordPress 6.8 and WP-CLI 2.11 on PHP 8.2/8.3, Apache 2.4 or nginx 1.24+. Multisite has behaved this way since 4.5, when per-site custom domains landed in core.
  • Pretty permalinks already active. Multisite will not run on the plain ?p=123 structure — check with wp option get permalink_structure.
  • Shell access with WP-CLI, plus write access to wp-config.php and to either .htaccess or the server config.
  • DNS control at the authoritative provider. For the subdomain model specifically, the ability to create a wildcard record.
  • For the subdomain model, a way to issue a wildcard certificate. Public CAs only issue wildcards through the DNS-01 challenge, so your ACME client needs an API credential for the zone. HTTP-01 cannot produce a wildcard.
  • Be honest about shared hosting. Many shared cPanel plans refuse a * subdomain entry from the user-level interface, and AutoSSL issues per-hostname certificates rather than wildcards. That does not block the subdomain model — it means every new sub-site needs a subdomain entry and an AutoSSL run before it answers over HTTPS. Fine for six sites, tedious at sixty. Confirm both capabilities with the host before you pick.

How it works

Multisite boots differently. wp-settings.php sees MULTISITE defined and loads ms-settings.php very early — before plugins, before the theme. That file exists to answer one question: which row in the wp_blogs table does this request belong to?

It has two inputs, the Host header and the request path. DOMAIN_CURRENT_SITE and PATH_CURRENT_SITE say where the network itself lives; SUBDOMAIN_INSTALL says which of the two inputs carries site identity.

  • On a subdomain network the hostname carries identity. shop.example.com is matched against the domain column, with path /.
  • On a subdirectory network the hostname is constant and the first path segment carries identity. /shop/anything/ is matched as domain example.com, path /shop/.

Once the row is found, $blog_id is set and the table prefix becomes wp_<id>_ for that site’s own tables — site 1 keeps the bare prefix. Everything downstream (home, siteurl, the uploads directory under wp-content/uploads/sites/<id>/, the REST base) derives from the resolved site.

Two consequences fall out, and they are the whole decision:

Subdomain networks need every hostname to resolve and to be covered by a certificate before WordPress sees the request. A sub-site whose hostname DNS does not know about never reaches PHP, so the failure surfaces in the browser rather than anywhere you can debug from inside WordPress.

Subdirectory networks need rewrite rules, because /shop/wp-admin/ and /shop/wp-includes/js/jquery/jquery.min.js must be stripped back to real filesystem paths before Apache or nginx can serve them. The first path segment also becomes reserved namespace: a site slug and a top-level page slug cannot both be shop.

Side-by-side topology comparison: the subdomain model needs a wildcard DNS record and a wildcard certificate feeding one WordPress install that matches the Host header to a site ID, while the subdirectory model uses a single host plus rewrite rules and matches the first path segment; both share one core, one plugin and theme set, one wp-config.php and one database

Step-by-step

1. Decide the model before touching anything. Three questions, in order, and the first one is a hard gate rather than a preference.

Decision tree with three questions: whether wildcard DNS and a wildcard certificate are available, whether the sites should read as independent properties, and whether any site will move onto its own domain later; a no on the first question forces subdirectory, and notes cover the subdirectory age gate and core domain mapping

Can you create *.example.com and issue a certificate covering it — or at least add a hostname and a certificate every time a site is created? If not, subdirectory, and the decision is over.

Should the sites read as independent properties? Search engines treat a subdomain as a more separate entity than a subdirectory: signals consolidate less readily across shop.example.com and example.com than across example.com/shop/ and the root. That cuts both ways. A regional or franchisee site usually benefits from sitting inside the parent domain; a genuinely different brand usually does not want to inherit or contribute to the parent’s reputation.

Will any site move onto its own domain later? Core has mapped sites onto custom domains since WordPress 4.5, so either model gets there — no sunrise.php, no mapping plugin. The difference is cost. Retargeting shop.example.com to shop.example.ca is a hostname swap. Retargeting example.com/shop/ also changes the path from /shop/ to /, rewriting every internal URL in that site’s content and needing a redirect map on the old path.

One gate when converting an existing site rather than starting fresh: core hides the subdirectory option once the install has a published post older than a month, because old permalinks would collide with new site slugs. The allow_subdirectory_install filter overrides the check, but the collision risk it warns about is real.

2. Confirm the base install can host a network.

wp core version
wp option get permalink_structure
wp core is-installed --network && echo "already a network"
6.8.1
/%postname%/

An empty third line means you are on a single site, which is what you want. A blank permalink_structure has to be fixed first with wp rewrite structure '/%postname%/'.

3. Open the network setup path. This constant only exposes the machinery; it does not create anything.

wp config set WP_ALLOW_MULTISITE true --raw
wp config get WP_ALLOW_MULTISITE
Success: Updated the constant 'WP_ALLOW_MULTISITE' in the 'wp-config.php' file with the raw value 'true'.
true

4. Create the network. WP-CLI writes the constants and the network tables in one command. Converting an existing single site to a subdomain network:

wp core multisite-convert --subdomains --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 the subdirectory model, drop the flag and set the base path explicitly:

wp core multisite-convert --title='Example Network' --base=/

On a brand-new install with no content, wp core multisite-install does the site install and the network creation together and takes the same --subdomains and --base flags. The web equivalent is Tools → Network Setup, documented in the WordPress network creation guide.

5. Read back the constants WP-CLI wrote. These five are the network’s entire addressing configuration.

for c in MULTISITE SUBDOMAIN_INSTALL DOMAIN_CURRENT_SITE PATH_CURRENT_SITE SITE_ID_CURRENT_SITE; do
  printf '%s = %s\n' "$c" "$(wp config get "$c")"
done
MULTISITE = true
SUBDOMAIN_INSTALL = true
DOMAIN_CURRENT_SITE = example.com
PATH_CURRENT_SITE = /
SITE_ID_CURRENT_SITE = 1

SUBDOMAIN_INSTALL is the one that matters here. DOMAIN_CURRENT_SITE and PATH_CURRENT_SITE locate the network’s own root and are what ms-settings.php falls back to when no site row matches. On a network installed under a path rather than at the root, PATH_CURRENT_SITE holds that path and site slugs are appended to it.

6. Install the rewrite rules. The two models get different Apache blocks, and they are not interchangeable. Subdomain:

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]

Subdirectory, where the extra ^([_0-9a-zA-Z-]+/)? group is what strips the site slug off core paths:

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]

On nginx a subdomain network needs nothing beyond the standard single-site try_files. A subdirectory network needs two extra rewrites inside the server block, above the location / that holds try_files:

rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;

Reload and confirm a core asset still resolves through a site slug:

curl -o /dev/null -s -w '%{http_code}\n' https://example.com/shop/wp-includes/js/wp-emoji-release.min.js
200

A 404 there means the rewrite block did not take, and every sub-site will load unstyled.

7. Wildcard DNS, subdomain model only. Add an A record for * in the zone pointing at the same address as the apex, then prove it resolves for a hostname that has never existed:

dig +short example.com A
dig +short never-created-yet.example.com A
203.0.113.10
203.0.113.10

Both lines must match. On cPanel, create a subdomain named * under Domains; on WHM you can edit the zone directly. A wildcard record does not shadow explicit records — a specific mail.example.com A record still wins over *.

8. Wildcard certificate, subdomain model only. Wildcards require DNS-01, so the ACME client needs zone API credentials. With Certbot and a DNS plugin:

certbot certonly --dns-cloudflare \
  --dns-cloudflare-credentials /etc/letsencrypt/cloudflare.ini \
  -d example.com -d '*.example.com'
Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/example.com/fullchain.pem

Two facts catch people out: *.example.com does not cover example.com itself, which is why the apex is listed separately above, and it does not cover a.b.example.com — a wildcard matches exactly one label. Without a wildcard, per-hostname certificates work; issuing one becomes part of your site-creation runbook rather than an afterthought.

Validate it works

Create a real test site and prove the three things that actually break: routing, TLS, and login.

wp site create --slug=shop --title='Shop' --email='ops@example.com'
wp site list --fields=blog_id,url,registered
Success: Site 2 created: https://shop.example.com/
+---------+----------------------------+---------------------+
| blog_id | url                        | registered          |
+---------+----------------------------+---------------------+
| 1       | https://example.com/       | 2026-08-23 14:02:11 |
| 2       | https://shop.example.com/  | 2026-08-23 14:06:40 |
+---------+----------------------------+---------------------+

On a subdirectory network the same command produces https://example.com/shop/ instead. Either way, the URL printed there is what everything else derives from.

Routing and TLS in one shot:

curl -sI https://shop.example.com/ | head -1
openssl s_client -connect shop.example.com:443 -servername shop.example.com </dev/null 2>/dev/null \
  | openssl x509 -noout -ext subjectAltName
HTTP/2 200
X509v3 Subject Alternative Name:
    DNS:*.example.com, DNS:example.com

A curl: (60) certificate error instead of the 200 means DNS resolved but the certificate does not cover the new hostname — step 8, not step 7.

Confirm WordPress itself agrees about where the site lives:

wp --url=https://shop.example.com option get home
wp --url=https://shop.example.com option get siteurl
https://shop.example.com
https://shop.example.com

Now log in. Load https://shop.example.com/wp-admin/, sign in as a network administrator, and confirm you land in that site’s dashboard with My Sites → Network Admin in the toolbar. Upload a small image and check where it lands:

wp --url=https://shop.example.com option get upload_path
ls wp-content/uploads/sites/2/

An empty upload_path is normal; the sites/2/ directory appearing means the site ID resolved correctly all the way through the media handler.

Check cookie scope explicitly — it is where the two models quietly diverge:

wp eval 'echo (defined("COOKIE_DOMAIN") ? var_export(COOKIE_DOMAIN, true) : "undefined") . PHP_EOL;'
wp eval 'echo ADMIN_COOKIE_PATH . PHP_EOL;'

On a subdirectory network every site shares one hostname, so a single auth cookie scoped at / covers the whole network. On a subdomain network each hostname is its own cookie scope: with COOKIE_DOMAIN false or undefined the cookie binds to the exact host that issued it. Setting it to .example.com makes one cookie cover every sub-site — and breaks the moment a site is mapped onto its own domain, since that host is no longer under .example.com. On a network that will ever use custom domains, leave it alone.

Troubleshooting

A new sub-site does not resolve at all. The browser reports a DNS failure and nothing appears in the access log. There is no wildcard record, or the wildcard exists at the registrar but the zone is served elsewhere. Test with a hostname you have never used — dig +short random-string.example.com A — since an existing explicit record will mask a missing wildcard.

The site resolves but the browser refuses it over HTTPS. NET::ERR_CERT_COMMON_NAME_INVALID, or curl: (60). The certificate does not list the new hostname. Read the SANs with the openssl x509 -noout -ext subjectAltName command above. On cPanel AutoSSL this is the normal state after creating a site: the certificate is reissued only after the hostname is registered as a subdomain and AutoSSL has run.

A subdirectory sub-site shows the wrong content, or a 404. The slug collides with something at the top level — a page, a category base, a RewriteRule in .htaccess, or a real directory on disk. Core reserves obvious names at creation time but cannot see your page slugs. Rename one of the two; the site slug is editable in Network Admin → Sites → Edit, which is cheap while the site is empty and painful later.

Redirect loop after network creation. curl -I shows an endless chain between example.com and a sub-site, or between HTTP and HTTPS. Usually DOMAIN_CURRENT_SITE disagrees with home and siteurl in the database — commonly a www mismatch. Compare wp config get DOMAIN_CURRENT_SITE against wp option get siteurl and make one of them yield. A canonical HTTPS or www redirect running ahead of the WordPress rewrite block is the other common cause.

Logged in on one sub-site, logged out on the next. Subdomain networks only. Each host holds its own cookie unless COOKIE_DOMAIN says otherwise. This is expected behaviour rather than a fault, and it is the right default on any network that will map custom domains. The multisite operations guide covers the day-to-day management side, and common multisite issues has more on the failure modes specific to shared hosting.

When this is the wrong approach

Multisite is a fleet-management tool. It pays off when one team runs many similar sites and wants a single core, a single plugin set, and one update covering all of them. Outside that shape, separate installs usually win.

Run separate installs when the sites have different owners. Multisite gives no real isolation: a network administrator sees every site, any network-activated plugin runs everywhere, and a security incident in one site is an incident in the whole network, since they share a filesystem and a database.

Run separate installs when the sites need different plugin versions or conflicting plugins. There is one wp-content directory. Two sites that need incompatible versions of the same plugin cannot both be right.

Run separate installs when only one site actually matters. A busy commercial site sharing a database with four brochure sites inherits their queries and their update windows for no benefit.

Run separate installs when a site may be sold or spun out. Extracting one site from a network means a table-by-table export, a rewrite of every URL, and a media move; handing over a standalone install is a filesystem copy and a database dump.

And if what you want is one site published in several languages, a multilingual plugin on a single install is almost always less work than a network. Still leaning toward a network? The cPanel multisite setup guide and the advanced administration documentation cover the install mechanics in more depth than this comparison does.

Running WordPress that earns real money deserves an operator — Stack Harbor runs that stack under Enterprise WordPress; book an infrastructure consult.