Domain mapping multisite subdirectory- get_sites() returns empty
-
Hiya! I’ve got a multisite sub-directory setup we have run since 2013 at mysite.blah.ca (works great, latest version, .htaccess matches setup recommendations checked, etc).
I’d like to map a domain (maptest.blah.ca) to one of the child sites. The problem is, the new domain does not resolve to the child site (it redirects to the main URL), seemingly because there is no matching wp_blogs table entry.Following the directions at
https://ww.wp.xz.cn/support/article/wordpress-multisite-domain-mapping/
I’ve got the domain resolving to the host and showing the content.
Still following those directions I edit a child site and set Info tab > Site Address (URL) = https://maptest.blah.ca/I worked through the code flow with debug statements and found it’s ending up going through wp-includes/ms-site.php::get_sites() and not finding any match
Logs
[17-Mar-2022] ms_load_current_site_and_network::Started with $domain=maptest.blah.ca, $path=/, $subdomain= [17-Mar-2022] ms_load_current_site_and_network::The network is defined in wp-config.php [17-Mar-2022] ms_load_current_site_and_network::323::Built $current_site=stdClass Object ( [id] => 1 [domain] => maptest.blah.ca [path] => / [blog_id] => 1 ) [17-Mar-2022] get_site_by_path::Started with $domain=maptest.blah.ca, $path=/, $segments= [17-Mar-2022] get_site_by_path::Before segments filter $domain=maptest.blah.ca [17-Mar-2022] get_site_by_path::After segments filter $domain=maptest.blah.ca [17-Mar-2022] get_site_by_path::Found $path_segments=Array ( ) [17-Mar-2022] get_site_by_path::Found $paths=Array ( [0] => / ) [17-Mar-2022] get_site_by_path::Before pre_get_site_by_path $domain=maptest.blah.ca [17-Mar-2022] get_site_by_path::After pre_get_site_by_path [17-Mar-2022] get_site_by_path::About to www domain with $domain=maptest.blah.ca [17-Mar-2022] get_site_by_path::Found $domains=Array ( [0] => maptest.blah.ca ) [17-Mar-2022] get_site_by_path::About to get_sites with args=Array ( [number] => 1 [update_site_meta_cache] => [domain] => maptest.blah.ca [path] => / ) [17-Mar-2022] get_sites::419::Started with args=Array ( [number] => 1 [update_site_meta_cache] => [domain] => maptest.blah.ca [path] => / ) [17-Mar-2022] get_sites::427::Last query=SELECT wp_blogs.blog_id FROM wp_blogs WHERE domain = 'maptest.blah.ca' AND path = '/' ORDER BY wp_blogs.blog_id ASC LIMIT 1 [17-Mar-2022] get_site_by_path::After get_sites, $site= [17-Mar-2022] ms_load_current_site_and_network::327::Built $current_blog= [17-Mar-2022] ms_load_current_site_and_network::Got $current_site=stdClass Object ( [id] => 1 [domain] => maptest.blah.ca [path] => / [blog_id] => 1 ) and $current_blog= [17-Mar-2022] ms_load_current_site_and_network::No site has been found so bail [17-Mar-2022] ms-settings.php::Built $bootstrap_result= [17-Mar-2022] ms-settings.php::About to redirect to Location=https://mysite.blah.ca/Indeed there’s no match in the DB table. This table has always looked like this.
mysql> SELECT * FROM wp_blogs ORDER BY wp_blogs.blog_id ASC LIMIT 1; +---------+---------+----------------+------+---------------------+---------------------+--------+----------+--------+------+---------+---------+ | blog_id | site_id | domain | path | registered | last_updated | public | archived | mature | spam | deleted | lang_id | +---------+---------+----------------+------+---------------------+---------------------+--------+----------+--------+------+---------+---------+ | 1 | 1 | mysite.blah.ca | / | 2013-01-10 19:43:29 | 2022-02-13 00:01:57 | 1 | 0 | 0 | 0 | 0 | 0 | +---------+---------+----------------+------+---------------------+---------------------+--------+----------+--------+------+---------+---------+.htaccess
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / #WP core rule for WPMS RewriteRule ^/?([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [NC,L] #WORDPRESS-1390 This replaces the WP core rule: RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L] RewriteCond %{REQUEST_URI} ^/?([_0-9a-zA-Z-]+/)?(.*\.php)$ [NC] RewriteCond %{DOCUMENT_ROOT}/$1 -f RewriteRule ([^/]+\.php)$ $1 [NC,L] #WP core rule for WPMS RewriteRule . index.php [L] #WORDPRESS-1390 Run non-existent file requests through the WordFence firewall #This should be just above the final WP multisite redirects RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule . index.php [L] </IfModule>wp-config.php
<?php define('DB_NAME', 'snipped'); define('DB_USER', 'snipped'); define('DB_PASSWORD', 'snipped'); define('DB_HOST', 'snipped'); define('WP_DEBUG', 1); $table_prefix = 'wp_'; if (WP_DEBUG) { ini_set('log_errors', 1); ini_set('error_log', dirname(__FILE__) . '/wp-content/debug.log'); error_reporting(E_ALL | E_STRICT); } define('WP_DEBUG_LOG', WP_DEBUG); define('WP_DEBUG_DISPLAY', 0); if (WP_DEBUG_DISPLAY) { ini_set('display_errors', 1); } /* Multisite */ define('WP_ALLOW_MULTISITE', true); define('MULTISITE', true); define('SUBDOMAIN_INSTALL', false); define('PATH_CURRENT_SITE', '/'); define('SITE_ID_CURRENT_SITE', 1); define('BLOG_ID_CURRENT_SITE', 1); /* * Requests come from the client to the load balancer as https, but are translated to http from the the LB to the web server. * Unfortunately the LB does not tell the server it is working over https in a way WP understands, so the is_ssl() function returns the wrong result. * Forcing SSL gets around the problem. */ $_SERVER['HTTPS'] = 'on'; $_SERVER['SERVER_PORT'] = 443; /** Sets up WordPress vars and included files. */ require_once(ABSPATH . 'wp-settings.php');Any hints how to get this working?
The topic ‘Domain mapping multisite subdirectory- get_sites() returns empty’ is closed to new replies.