Hosting multiple domains on WPMU

Yep, I’m as surprised as you are – why wouldn’t something like this be built in? The goal here is to set up multiple blog web sites on a single WordPress MU instance (ver. 2.9.2 at the moment). Typically, this is easily done out of the box by configuring WPMU to use either subdirectories or subdomains; however, in both cases you cannot specify a different domain name per blog. The following instructions will get you past this limitation, but in this case our instructions will only apply to installations which use subdirectories for multiple blogs. You can easily modify these instructions to accommodate subdomains as well.

Add the following to your wp-config.php file, around line 52:

// Custom: overwitten by below
/*
$base = '/';
define('DOMAIN_CURRENT_SITE', 'www.domain-one.com' );
define('PATH_CURRENT_SITE', '/' );
define('SITE_ID_CURRENT_SITE', 1);
define('BLOGID_CURRENT_SITE', '1' );
*/

// Custom: handle multiple domains in WPMU
switch($_SERVER['SERVER_NAME']){
	case 'www.domain-one.com':
		define('DOMAIN_CURRENT_SITE', 'www.domain-one.com' );
		define('PATH_CURRENT_SITE', '/' );
		define('BLOGID_CURRENT_SITE', '1' );
		break;
	case 'www.domain-two.com':
		define('DOMAIN_CURRENT_SITE', 'www.domain-two.com' );
		define('PATH_CURRENT_SITE', '/' );
		define('BLOGID_CURRENT_SITE', '2' );
		break;
	default:
		define('DOMAIN_CURRENT_SITE', 'www.domain-one.com' );
		define('PATH_CURRENT_SITE', '/' );
		define('BLOGID_CURRENT_SITE', '1' );
		break;
	}
// end Custom

Basically, you’ll want to comment out where DOMAIN_CURRENT_SITE, and similar constant values are set. This switch will send you’re requests to the appropriate blogid.

In your individual blog settings you’ll want to configure the paths like so:

You can specify the blog’s domain name like so.

Leave a Reply

Your email address will not be published. Required fields are marked *


+ eight = 12

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>