Skip to content

How-to Guides

Technical References

Multisites /

Multiple domains

By default, VIP Go enforces the use of a single domain per site in a multisite (notably, this is not exactly the same as core multisite, which will cause a domain not associated with any site in the network to resolve to site_id 1.) Some VIPs have found it useful to allow multiple domains to resolve to a single site in the network either temporarily or permanently. In the example below, this multi-domain configuration is limited to REST API requests, but it could be more general, or differently targeted.

// Allow REST API requests to be served on one of several domains
$clientslug_custom_sunrise_domains = ['', '', ''];
// Cause each of these domains to load site_id 1
$clientslug_custom_sunrise_site_id = 1;
// @codingStandardsIgnoreLine -- use of $_SERVER okay here
if ( in_array( $_SERVER['HTTP_HOST'], $clientslug_custom_sunrise_domains, true ) && 0 === strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-json' ) ) {
	// These domains are each associated with site_id 1 of network 1
	$current_blog = get_site( $clientslug_custom_sunrise_site_id );
	$current_site = get_network( 1 ); // This should always be 1, unless you are running multiple WordPress networks.

Other uses of client-sunrise.php might include logic around redirects (that don’t require database lookups) or other manipulation of fundamental WordPress constants or globals based on the request.

If you have questions about whether a solution involving sunrise is appropriate for your situation, please reach out to VIP support.

Last updated: November 19, 2020