diff --git wp-includes/ms-blogs.php wp-includes/ms-blogs.php
index 34d6c28c76..b18ef17e69 100644
--- wp-includes/ms-blogs.php
+++ wp-includes/ms-blogs.php
@@ -87,8 +87,13 @@ function get_id_from_blogname( $slug ) {
 	$current_network = get_network();
 	$slug            = trim( $slug, '/' );
 
-	$domain = $current_network->domain;
-	$path   = $current_network->path . $slug . '/';
+	if ( is_subdomain_install() ) {
+		$domain = $slug . '.' . preg_replace( '|^www\.|', '', $current_network->domain );
+		$path   = $current_network->path;
+	} else {
+		$domain = $current_network->domain;
+		$path   = $current_network->path . $slug . '/';
+	}
 
 	$site_ids = get_sites(
 		array(
