You take over a multisite network that hosts 30 customer-facing brand sites, each on its own apex domain. Half the subsites still route through the abandoned wordpress-mu-domain-mapping plugin, the other half use core’s native mapping, and the certificate for the wildcard host expired 11 hours ago because the renewal cron only knew about the primary domain. Two subsites are throwing mixed-content warnings; one is serving the network signup page on its own domain. The previous operator’s runbook says “add the domain in Network Admin and it just works.” It does not just work — and the install-time decision between subdomain and subdirectory is now constraining what’s possible.
What’s happening
A multisite network is initialized with SUBDOMAIN_INSTALL set once, before sites exist. That value cannot be flipped safely later — true means each subsite lives at a hostname (brand1.network.example, brand2.network.example), false means each subsite lives at a path (network.example/brand1, network.example/brand2). Subdomain installs require wildcard DNS (*.network.example) and a wildcard TLS certificate that covers it. Subdirectory installs do not need wildcards but must rewrite permalinks, and subsite slugs collide with any top-level path the network uses (/wp-admin/, /wp-content/, /feed/, /blog/).
On top of that base, the operator wants each subsite reachable on its own apex (brand1.com, not brand1.network.example). That mapping was historically done with the WPMU Domain Mapping plugin, which installed a wp_domain_mapping table and a custom sunrise.php drop-in to intercept the request before WordPress booted. WordPress 4.5 merged domain mapping into core: wp_blogs.domain holds the mapped domain, wp_blogs.path holds /, and no plugin is required. The plugin still works, but it shadows core’s logic, and most networks that look broken are running both at once.
The TLS side is the operational trap. A subdomain install with native core mapping serves three address spaces from one WordPress: the network host, the wildcard pattern under it, and N apex domains added through mapping. Let’s Encrypt issuance has to cover all three. A wildcard certificate via DNS-01 covers the first two; per-domain certificates via HTTP-01 cover the apex domains. A renewal cron that only knows about the wildcard will let mapped apex certs lapse silently.
How to verify
Confirm which mode your network is in:
wp config get SUBDOMAIN_INSTALL
wp config get DOMAIN_CURRENT_SITE
wp config get PATH_CURRENT_SITE
wp config get MULTISITE
Inspect a specific subsite’s mapped domain and path:
wp site list --fields=blog_id,domain,path,registered,last_updated
A correctly mapped apex subsite shows brand1.com in domain and / in path. A subsite still routed only through the network shows brand1.network.example in domain. If the domain column shows the apex and the path shows /brand1/, the row is corrupt — that combination only makes sense in a subdirectory install with no mapping.
Check for legacy plugin residue:
wp plugin list --network --status=active | grep -i domain-mapping
wp eval 'global $wpdb; var_dump($wpdb->get_results("SHOW TABLES LIKE \"{$wpdb->prefix}domain_mapping\""));'
ls -la wp-content/sunrise.php 2>/dev/null
wp config get SUNRISE 2>/dev/null
If SUNRISE is true and the plugin’s sunrise.php is in place, requests are being intercepted by the plugin’s logic, not core’s — even on a current WordPress version. That’s the most common cause of “I added the domain in Network Admin and nothing happened.”
Verify DNS for one mapped domain end-to-end:
# Wildcard for the network itself
dig +short '*.network.example' @1.1.1.1
dig +short brand1.network.example @1.1.1.1
# Mapped apex
dig +short brand1.com @1.1.1.1
dig +short www.brand1.com @1.1.1.1
Then verify the certificate chain actually presents the right SANs:
echo | openssl s_client -connect brand1.com:443 -servername brand1.com 2>/dev/null \
| openssl x509 -noout -text \
| grep -A1 'Subject Alternative Name'
echo | openssl s_client -connect blog.network.example:443 -servername blog.network.example 2>/dev/null \
| openssl x509 -noout -text \
| grep -A1 'Subject Alternative Name'
A working setup has one wildcard cert covering *.network.example, network.example and N per-domain certs covering each mapped apex (with www. and the apex on the same cert). A broken setup has the network apex cert presented for a mapped domain — the browser shows a name mismatch, and the operator usually blames the CDN.
The fix
If you have a clean install ahead of you and the choice is open, pick subdomain mode. Subdirectory mode trades a single wildcard cert for an ongoing slug-collision tax: every plugin that adds a top-level rewrite (/cart/, /learn/, /api/) can collide with a subsite, and the operator has to remember the conflict at the moment the subsite is created. Subdomain mode pays its tax once, up front, in DNS and certificate provisioning. Both are stable; only one keeps being expensive forever.
The wp-config.php block for a subdomain network with mapping:
define( 'WP_ALLOW_MULTISITE', true );
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', true );
define( 'DOMAIN_CURRENT_SITE', 'network.example' );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );
# Cookie domain — leave undefined so each mapped domain gets its own cookies.
# Defining COOKIE_DOMAIN forces shared-cookie behavior, which breaks mapped subsites.
Do not set SUNRISE for native core mapping; that constant only matters when a sunrise.php drop-in exists. If the legacy domain-mapping plugin is still installed, remove its sunrise.php after migrating mapped rows into wp_blogs:
# Migrate from wp_domain_mapping to wp_blogs.domain
wp db query "SELECT m.blog_id, m.domain, b.domain AS current
FROM wp_domain_mapping m
JOIN wp_blogs b ON b.blog_id = m.blog_id
WHERE m.active = 1;"
# For each row, update wp_blogs (replace 7 and brand1.com with real values)
wp db query "UPDATE wp_blogs SET domain='brand1.com', path='/' WHERE blog_id=7;"
# Deactivate and remove the legacy plugin network-wide
wp plugin deactivate wordpress-mu-domain-mapping --network
wp plugin delete wordpress-mu-domain-mapping
# Remove the drop-in and clear the SUNRISE constant
rm wp-content/sunrise.php
wp config delete SUNRISE
# Flush rewrite rules across the network
for id in $(wp site list --field=blog_id); do
wp rewrite flush --url=$(wp site url $id)
done
After the migration, validate every mapped subsite resolves and serves correctly:
for id in $(wp site list --field=blog_id); do
url=$(wp site url $id)
code=$(curl -s -o /dev/null -w '%{http_code}' -L "$url")
echo "$id $code $url"
done
Any non-200 result is a real problem — a 301 redirect loop, a 503 from a misconfigured upstream, or a 404 because the rewrite flush didn’t take.
For DNS, on a subdomain install you need three record types: the wildcard A/AAAA, the per-domain A/AAAA for each mapped apex, and ideally a CAA record so Let’s Encrypt is permitted to issue:
*.network.example. 300 IN A 203.0.113.45
network.example. 300 IN A 203.0.113.45
brand1.com. 300 IN A 203.0.113.45
www.brand1.com. 300 IN CNAME brand1.com.
brand1.com. 300 IN CAA 0 issue "letsencrypt.org"
For certificates with acme.sh and DNS-01 for the wildcard, HTTP-01 for the apex domains:
# Wildcard — needs a DNS API provider for the network's zone
acme.sh --issue --dns dns_cf -d network.example -d '*.network.example'
# Per-mapped-apex — HTTP-01 served from the multisite itself
acme.sh --issue -d brand1.com -d www.brand1.com --webroot /var/www/wp
# Install the cert into your web server config (nginx example)
acme.sh --install-cert -d brand1.com \
--key-file /etc/nginx/certs/brand1.com.key \
--fullchain-file /etc/nginx/certs/brand1.com.fullchain.pem \
--reloadcmd "systemctl reload nginx"
Whatever issues the certs has to know about every mapped apex. The simplest pattern: a nightly job that reads wp site list --field=domain, diffs it against the cert inventory, and triggers issuance for any new mapped domain.
The nginx server block for the network host accepts the wildcard and routes:
server {
listen 443 ssl http2;
server_name network.example *.network.example;
ssl_certificate /etc/nginx/certs/network.example.fullchain.pem;
ssl_certificate_key /etc/nginx/certs/network.example.key;
root /var/www/wp;
index index.php;
location / { try_files $uri $uri/ /index.php?$args; }
location ~ \.php$ { fastcgi_pass unix:/run/php-fpm.sock; include fastcgi_params; }
}
And a per-mapped-domain server block (one per apex, generated):
server {
listen 443 ssl http2;
server_name brand1.com www.brand1.com;
ssl_certificate /etc/nginx/certs/brand1.com.fullchain.pem;
ssl_certificate_key /etc/nginx/certs/brand1.com.key;
root /var/www/wp;
index index.php;
location / { try_files $uri $uri/ /index.php?$args; }
location ~ \.php$ { fastcgi_pass unix:/run/php-fpm.sock; include fastcgi_params; }
}
Same docroot, different server_name, different cert. WordPress’s mapping logic figures out which subsite the request belongs to from the Host header.
Stack Harbor runs multisite networks with native domain mapping, wildcard issuance, and per-apex renewal under managed enterprise WordPress hosting operations, and handles the DNS + certificate side through Deployment Management. If you’ve inherited a network that still routes through the legacy mapping plugin, we can plan the migration off it.