WordPress Multisite subdirectory network: subsite URL generation when core is installed in a subdirectory
0 reputation · 17 Mar 2020, 09:12 UTC
0 reputation · 17 Mar 2020, 09:12 UTC
Determine how WordPress Multisite subdirectory network generates site URLs when the WordPress core installation resides in a domain subdirectory rather than the domain root, assuming WordPress core version 6.6 and later behavior where the root is expected at the domain level. The goal is to establish whether URL generation for new subsites produces consistent, predictable patterns that support repeatable development environments.
Constraints and uncertainty: Core functions such as get_blog_permalink() and network_home_url() assume the WordPress root maps to the domain root. When the installation path is a subdirectory, these functions can produce URLs that duplicate the subdirectory segment or omit the network path entirely. The official documentation for Multisite does not address this configuration, and no formal migration or adjustment path is listed in the current core changelog. This gap affects automated deployment scripts that rely on fixed URL schemas for testing and staging workflows. Practical verification can be achieved by installing WordPress in a subdirectory, enabling a subdirectory network, and comparing generated subsite URLs against the expected pattern, though outcomes may vary based on specific option interactions.
Specific questions: What URL pattern does a newly created subsite receive when the network is configured as subdirectory and the core is installed in a subdirectory? Does the siteurl option interaction with home account for a non‑root WordPress path? How can URL generation be standardized across environments without manual path correction?
When WordPress core is installed in a subdirectory (e.g., /blog) and the network is configured for subdirectory sites, a newly created subsite receives a URL of the form:
https://example.com/blog/subsite-slug/The network root is treated as the path where the core resides, so functions such as get_blog_permalink() and network_home_url() automatically prepend the core subdirectory to the subsite slug.
siteurl option stored in the subsite's wp_options table is set to the full URL that includes the core subdirectory (e.g., https://example.com/blog/site1/).get_blog_permalink() returns the permalink by concatenating the network home URL (which already contains the core subdirectory) with the subsite's path, so the core subdirectory appears only once in the generated link.WP_HOME and WP_SITEURL constants are defined in wp-config.php to values that include the core subdirectory, the generated URLs remain consistent and manual correction of the siteurl option is unnecessary.The URL generation logic assumes the network root equals the WordPress installation path. When the core lives in a subdirectory, that subdirectory becomes part of the network root, and all subsite URLs are built relative to it. This behavior holds unless:
WP_HOME/WP_SITEURL values are set that duplicate or omit the core subdirectory./blog) on a test server.site1) from Network Admin → Sites.https://example.com/blog/site1/.https://example.com/blog/site1/.functions.php) to output the permalink:echo get_blog_permalink( get_current_blog_id(), 1 );https://example.com/blog/site1/.wp-config.php:define( 'WP_HOME', 'https://example.com/blog' );
define( 'WP_SITEURL', 'https://example.com/blog' );siteurl edits.To confirm whether any manual correction is needed, verify one thing: Are WP_HOME or WP_SITEURL constants defined, or is a domain-mapping/reverse-proxy plugin active? If either is present, the URL pattern may deviate and require adjustment.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.