Skip to content

Subdomain and subdirectory structures

By default, all WordPress multisite environments on the VIP Platform are configured with a subdirectory structure. The SUBDOMAIN_INSTALL constant is defined at platform level in wp-config.php with a default value of false. This value cannot be overridden, even by defining the constant differently in vip-config.php or with any other methods.

Because the SUBDOMAIN_INSTALL is defined as false, when a new network site is added the Site Address (URL) value must be a subdirectory of the domain that is assigned to the main site (ID 1).

The Site Address (URL) for a network site can later be updated or launched with a custom domain, subdomain, or subdirectory (e.g. example.com, two.example.com, example.com/three) with the Network Sites launch tool.

A combination of network sites with both subdomain and subdirectory URL structures can exist on the same multisite. For example:

  • A collection of network sites with only subdirectory structures (e.g., example.com/one and example.com/two).
  • A collection of network sites with assigned custom domains and subdomains (e.g., example.com, another.example.com and one-more-example.com).
  • A collection of network sites that include both subdirectory and subdomain structures (e.g., example.com, example.com/oneanother.example.com, and one-more-example.com/two).

Subdirectory paths

By default a subdirectory structure with a single segment path (e.g.,example.com/one) is supported for the Site Address (URL) of network sites.

A Site Address (URL) subdirectory path with a maximum of two segments (e.g., example.com/one/two) can be code-enabled by using the site_by_path_segments_count filter.

In the code example below, $num_segments = 3; sets the subdirectory structure to allow:

  • the custom domain
  • the first subdirectory
  • and the second subdirectory.

Integers higher than 3 are not allowed. A version of the code example below should be added to /vip-config/client-sunrise.php:

/vip-config/client-sunrise.php
function my_filter_site_by_path_segments_count( $num_segments ) {
        $num_segments = 3;
        return $num_segments;
}
add_filter( 'site_by_path_segments_count', 'my_filter_site_by_path_segments_count', 99 );

Last updated: December 22, 2023

Relevant to

  • WordPress