Subdomains & subdirectories
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 of value of false
. This value cannot be overridden, even by defining the constant differently in vip-config.php or with any other methods.
To achieve the same effect as a subdomain multisite, custom domains and subdomains can be mapped to network sites (e.g. one.example.com
, two.example.com
). The URL for an existing network site can be edited and replaced with an entirely new URL, including a subdomain structure. When updating a network site to be reachable at a custom domain or subdomain, it is recommended to first add and map the domain to the environment so that the network site is web-accessible. If a network site URL is updated to a custom domain that is not yet added and pointed to the VIP environment, it will only be accessible by modifying a hosts file.
The Network Sites launch tool in the VIP Dashboard is recommended for updating a network site’s address URL structure.
A combination of both subdomain and subdirectory URL structures for network sites can exist within a single multisite such as:
- A collection of network sites with only subdirectory structures (e.g.,
example.com/one
andexample.com/two
). - A collection of network sites with assigned custom domains and subdomains (e.g.,
another.example.com
andfurther-example.com
). - A collection of network sites that include both subdirectory and subdomain structures (e.g.,
example.com
,example.com/one
,another.example.com
, andexample-another.com/two
).
Subdirectories
By default the VIP Platform supports a subdirectory site with a single segment path (e.g.,example.com/one
).
A subdirectory site path with a maximum of two segments (e.g., example.com/one/two
) can be enabled through code 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:
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: April 03, 2023