2026年11月12日

2026年11月12日

Fix WordPress Multisite Domain Errors: Subsites Not Loading, 404s

This article is a localized edition of the Japanese original. Read the Japanese original

On WordPress Multisite, problems like a subsite (site2.example.com or example.com/site2/) not loading, being redirected to the new-site signup page, or a custom domain that neither loads nor lets you log in almost always come from a mismatch in one of these places:

  • Constants in wp-config.php
  • The domain and path of each site stored in the database (the wp_blogs and wp_site tables)
  • DNS (for subdomain networks, the wildcard record)
  • Web server configuration (accepted hostnames and rewrite rules)
  • SSL certificates

This article helps you narrow down the cause from the symptom and then check and fix each item in the order above. Screen names and messages follow WordPress 7.1 (the latest version as of October 2026).

Before you start, back up the database and wp-config.php (you can export the database with wp db export).

Narrow down the cause from the symptom

Symptom Likely cause Step to check
Opening a subdomain subsite redirects to wp-signup.php?new=… (the new-site signup page) No site with that domain exists in wp_blogs (spelling, www or not, leftovers from a domain migration) Step 2
"Error establishing a database connection" appears (in the admin area the more detailed "Could not find site …" appears) DOMAIN_CURRENT_SITE and PATH_CURRENT_SITE do not match the values in wp_site and wp_blogs Steps 1 and 2
Opening a subdomain makes the browser say the server cannot be found No wildcard DNS record Step 3
Opening a subdomain shows a different site or the web server's default page The web server does not accept that hostname Step 4
Only subdirectory subsites return 404, or the admin CSS is broken .htaccess or nginx rewrite rules are missing or outdated Step 4
Certificate errors The certificate does not cover the subdomains or the custom domain Step 5
The login page on a custom domain shows a cookie error, or logging in just returns you to the login page Cookie domain Step 6
/wp-admin/network/ shows "Multisite support is not enabled." The MULTISITE constant is not defined Step 1

Step 1: Check the constants in wp-config.php

Use the Multisite constants that were shown when you created the network under "Tools" → "Network Setup" in the admin area. For a subdomain network they look like this:

<?php
// Put this in wp-config.php above the "stop editing" line (in the Japanese edition: "編集が必要なのはここまでです")
define( 'WP_ALLOW_MULTISITE', true );
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', true ); // false for a subdirectory network
define( 'DOMAIN_CURRENT_SITE', 'example.com' );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );

Things to check:

  • DOMAIN_CURRENT_SITE contains only the main site's domain, without https:// or a trailing /. If you run the site with www, include www.
  • PATH_CURRENT_SITE is / if WordPress is installed at the domain root.
  • SUBDOMAIN_INSTALL matches the type chosen when the network was created.

With WP-CLI you can check them like this:

wp config get MULTISITE
wp config get SUBDOMAIN_INSTALL
wp config get DOMAIN_CURRENT_SITE
wp config get PATH_CURRENT_SITE

Constants such as UPLOADBLOGSDIR, which point uploads to the old blogs.dir, are not needed for current Multisite. In networks created with WordPress 3.5 or later, subsite files are stored in wp-content/uploads/sites/SITE_ID/.

Step 2: Check the domains and paths in the database

WordPress decides which site to show by matching the requested domain and path against the wp_blogs table. If you visit a domain that is not in it, a subdomain network redirects you to the new-site signup page.

# Domain and path of each site
wp site list --fields=blog_id,domain,path,url

# Domain and path of the network (main site)
wp db query "SELECT id, domain, path FROM wp_site;"

If you changed the table prefix from wp_, adjust wp_site to your prefix (you can check it with wp db prefix).

Things to check:

  • Do domain and path in wp_site match DOMAIN_CURRENT_SITE and PATH_CURRENT_SITE from Step 1?
  • Does the domain you open in the browser match domain in wp_blogs (including www or not)?

If sites stopped loading after a domain move

After migrating from another domain, the old domain is often still in the database. Running WP-CLI's search-replace with --network replaces it in all network tables, including wp_blogs and wp_site. Because WordPress has to load under the old domain, pass the old domain with --url.

# First, only check how many changes would be made
wp search-replace --url=old.example 'old.example' 'example.com' --network --skip-columns=guid --dry-run

# If it looks right, run it
wp search-replace --url=old.example 'old.example' 'example.com' --network --skip-columns=guid

After the replacement, also change DOMAIN_CURRENT_SITE from Step 1 to the new domain.

Step 3: Check DNS (subdomain networks)

For subdomain networks it is common to set a wildcard A record, so you do not have to add DNS records every time you create a subsite.

*.example.com.  A  203.0.113.10

Look up a subdomain that does not exist and check that the server's IP address comes back:

dig +short test-abc.example.com

If nothing is returned, add the wildcard record in your DNS management panel. See also Setting up a wildcard DNS record. If your DNS service does not support wildcards, add an A record (or CNAME) for each subsite.

Step 4: Check the web server configuration

Apache

For a subdomain network, set ServerAlias so that the virtual host also accepts subdomains.

<VirtualHost *:443>
    ServerName example.com
    ServerAlias *.example.com
    DocumentRoot /var/www/example.com
    <Directory /var/www/example.com>
        AllowOverride All
    </Directory>
    # SSL settings omitted
</VirtualHost>

For the .htaccess rewrite rules, use the ones from the official WordPress documentation below (they are also shown on the "Network Setup" screen).

Subdomain network:

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 network:

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 files/ line that routes to wp-includes/ms-files.php is for networks created before WordPress 3.5. Networks created with 3.5 or later do not use it.

nginx

For a subdomain network, add a wildcard to server_name.

server {
    server_name example.com *.example.com;
    root /var/www/example.com;
    index index.php;

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

    # PHP (location ~ \.php$) and SSL settings omitted
}

For a subdirectory network, add the following rewrites from the official documentation to the server block. Without them, subsite admin screens, CSS and JavaScript return 404.

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

After changing the configuration, check it with sudo nginx -t and apply it with sudo systemctl reload nginx.

Step 5: Check the SSL certificates

  • A subdomain network needs a wildcard certificate covering *.example.com. A wildcard certificate covers only one level and does not include example.com itself, so request it with both example.com and *.example.com.
  • Getting a wildcard certificate from Let's Encrypt requires DNS validation (DNS-01) (How to get a wildcard certificate from Let's Encrypt).
  • A subsite mapped to a custom domain also needs a separate certificate for that domain.

Step 6: Map a custom domain (domain mapping)

Since WordPress 4.5 you can map a custom domain to a subsite without a plugin.

  1. Point the A record of the custom domain (for example custom-domain.com) to the IP address of the server running the network.
  2. Make the web server accept that domain (add it to ServerAlias in Apache or server_name in nginx).
  3. Prepare an SSL certificate for that domain.
  4. In Network Admin, go to "Sites", open "Edit" for the subsite, change "Site Address (URL)" to https://custom-domain.com and save.

If logging in to the custom-domain subsite gives a cookie error, or logging in just sends you back to the login screen, add the following line below the network constants, as the official documentation describes.

<?php
// wp-config.php: add only if you cannot log in on the custom domain
define( 'COOKIE_DOMAIN', $_SERVER['HTTP_HOST'] );

sunrise.php (define( 'SUNRISE', true );) is only for domain mapping plugins that require it. You do not need it when you map domains with WordPress core's built-in feature.

Notes

  • You cannot switch between subdomain and subdirectory networks just by changing the constants after the network has been created. The domains and paths of existing sites in wp_blogs stay as they are, so decide on the type before creating the network.
  • Shared hosting plans may restrict wildcard subdomains or adding custom domains. Check what your hosting service supports.
  • Editing wp_blogs directly with SQL can leave it out of sync with each site's home and siteurl options. Changing domains through Network Admin's "Edit Site" screen or with wp search-replace is safer.

Setting up a Multisite network itself is covered in How to set up WordPress Multisite.

Summary

  • First check that DOMAIN_CURRENT_SITE and PATH_CURRENT_SITE match the domains and paths in wp_site and wp_blogs.
  • A subdomain network needs three things together: wildcard DNS, a wildcard hostname in the web server, and a wildcard certificate.
  • If a subdirectory network returns 404, reinstall the official rewrite rules.
  • Map custom domains through "Site Address (URL)", and add COOKIE_DOMAIN only if you cannot log in.

Questions about WordPress? The publisher of this site is based in Japan and replies in Japanese. Contact (Japanese)

お気軽にご相談ください

お見積りへ お問い合わせへ
▲