Index: wp-includes/ms-blogs.php
===================================================================
--- wp-includes/ms-blogs.php	(revision 18480)
+++ wp-includes/ms-blogs.php	(working copy)
@@ -73,9 +73,12 @@
 	if ( is_subdomain_install() ) {
 		$url = "http://" . $domain.$path;
 	} else {
-		if ( $domain != $_SERVER['HTTP_HOST'] ) {
+		$domain_root = substr( $domain, strpos( $domain, '.' ) + 1 );
+		$host_root = substr( $_SERVER['HTTP_HOST'], strpos( $_SERVER['HTTP_HOST'], '.' ) + 1 );
+
+		if ( $domain != $_SERVER['HTTP_HOST'] && $domain_root == $host_root ) {
 			$blogname = substr( $domain, 0, strpos( $domain, '.' ) );
-			$url = 'http://' . substr( $domain, strpos( $domain, '.' ) + 1 ) . $path;
+			$url = 'http://' . $domain_root . $path;
 			// we're not installing the main blog
 			if ( $blogname != 'www.' )
 				$url .= $blogname . '/';
