In my multisite setup I have multiple environments that I want to share the same database, but use different domains.
- server1.example.com
- server2.example.com
- example.com
… each of those would point to the same database. This works perfectly fine in a standard WP install using define( 'WP_HOME', 'http://server1.example.com' );
and define( 'WP_SITEURL', 'http://server1.example.com' );
.
When you add multisite to the mix it breaks.
The problem is that the wp_blogs
table defines the domains too, so I need a way to define them in the config file. Is there anyway to do that?
When WordPress loads multisite, it includes the relevant MS specific files in
wp-settings.php
The relevant lines:
ms-settings.php
serves a similar purpose aswp-settings.php
: loads the multisite environment, and — more importantly for our purposes — sets up the current site (collection of blogs) and blog. But there’s also these few gems:Most important:
if(defined('SUNRISE'))
. This lets you drop asunrise.php
file in yourwp-content
directory. It gets included if youdefine('SUNRISE', true);
in yourwp-config.php
. This file is the same one that’s used for domain mapping to setup the current site and blog based on the custom domains. You can use it to set up your own site and blog rather than let WordPress do it for you.Quick example — this works okay, but probably needs some improvement.
Since @kaiser will likely chime in to say that
$_SERVER['HTTP_HOST']
is unreliable, you may want to make sure your server actually has it available.Or do something like this…
You can drop the above
sunrise.php
into your local install and putdefine('SUNRISE', true);
into your local’s wp-config.Not sure if this answers your question, but I found this: http://wordpress.org/support/topic/multiple-domain-with-multisite