Index: src/wp-includes/ms-settings.php
===================================================================
--- src/wp-includes/ms-settings.php	(revision 25017)
+++ src/wp-includes/ms-settings.php	(working copy)
@@ -22,18 +22,22 @@
 
 if ( !isset( $current_site ) || !isset( $current_blog ) ) {
 
-	$domain = addslashes( $_SERVER['HTTP_HOST'] );
-	if ( false !== strpos( $domain, ':' ) ) {
-		if ( substr( $domain, -3 ) == ':80' ) {
-			$domain = substr( $domain, 0, -3 );
-			$_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -3 );
-		} elseif ( substr( $domain, -4 ) == ':443' ) {
-			$domain = substr( $domain, 0, -4 );
-			$_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -4 );
-		} else {
-			wp_load_translations_early();
-			wp_die( __( 'Multisite only works without the port number in the URL.' ) );
+	if ( isset( $_SERVER['HTTP_HOST'] ) ) {
+		$domain = addslashes( $_SERVER['HTTP_HOST'] );
+		if ( false !== strpos( $domain, ':' ) ) {
+			if ( substr( $domain, -3 ) == ':80' ) {
+				$domain = substr( $domain, 0, -3 );
+				$_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -3 );
+			} elseif ( substr( $domain, -4 ) == ':443' ) {
+				$domain = substr( $domain, 0, -4 );
+				$_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -4 );
+			} else {
+				wp_load_translations_early();
+				wp_die( __( 'Multisite only works without the port number in the URL.' ) );
+			}
 		}
+	} else {
+		$domain = DOMAIN_CURRENT_SITE;
 	}
 
 	$domain = rtrim( $domain, '.' );
@@ -41,10 +45,14 @@
 	if ( substr( $cookie_domain, 0, 4 ) == 'www.' )
 		$cookie_domain = substr( $cookie_domain, 4 );
 
-	$path = preg_replace( '|([a-z0-9-]+.php.*)|', '', $_SERVER['REQUEST_URI'] );
-	$path = str_replace ( '/wp-admin/', '/', $path );
-	$path = preg_replace( '|(/[a-z0-9-]+?/).*|', '$1', $path );
-
+	if ( isset( $_SERVER['REQUEST_URI'] ) ) {
+		$path = preg_replace( '|([a-z0-9-]+.php.*)|', '', $_SERVER['REQUEST_URI'] );
+		$path = str_replace ( '/wp-admin/', '/', $path );
+		$path = preg_replace( '|(/[a-z0-9-]+?/).*|', '$1', $path );
+	} else {
+		$path = '/';
+	}
+	
 	$current_site = wpmu_current_site();
 	if ( ! isset( $current_site->blog_id ) )
 		$current_site->blog_id = $wpdb->get_var( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs WHERE domain = %s AND path = %s", $current_site->domain, $current_site->path ) );
@@ -63,7 +71,11 @@
 		} else
 			$blogname = substr( $domain, 0, strpos( $domain, '.' ) );
 	} else {
-		$blogname = htmlspecialchars( substr( $_SERVER[ 'REQUEST_URI' ], strlen( $path ) ) );
+		if ( isset( $_SERVER[ 'REQUEST_URI' ] ) )
+			$blogname = htmlspecialchars( substr( $_SERVER[ 'REQUEST_URI' ], strlen( $path ) ) );
+		else 
+			$blogname = htmlspecialchars( $path );	
+			
 		if ( false !== strpos( $blogname, '/' ) )
 			$blogname = substr( $blogname, 0, strpos( $blogname, '/' ) );
 		if ( false !== strpos( $blogname, '?' ) )
@@ -94,7 +106,7 @@
 
 	if ( ! defined( 'WP_INSTALLING' ) ) {
 		if ( $current_site && ! $current_blog ) {
-			if ( $current_site->domain != $_SERVER[ 'HTTP_HOST' ] ) {
+			if ( isset( $_SERVER[ 'HTTP_HOST' ] ) && $current_site->domain != $_SERVER[ 'HTTP_HOST' ] ) {
 				header( 'Location: http://' . $current_site->domain . $current_site->path );
 				exit;
 			}
