Index: bp-core/bp-core-catchuri.php
===================================================================
--- bp-core/bp-core-catchuri.php	(revision 3218)
+++ bp-core/bp-core-catchuri.php	(working copy)
@@ -58,10 +58,15 @@
 		if ( empty( $bp_uri[$key] ) ) unset( $bp_uri[$key] );
 
 	if ( defined( 'BP_ENABLE_MULTIBLOG' ) || 1 != BP_ROOT_BLOG ) {
-		/* If we are running BuddyPress on any blog, not just a root blog, we need to first
-		   shift off the blog name if we are running a subdirectory install of WPMU. */
-		if ( $current_blog->path != '/' )
-			array_shift( $bp_uri );
+		/* Any subdirectory names must be removed from $bp_uri. This includes two cases: (1) when WP is installed in a subdirectory, and (2) when BP is running on secondary blog of a subdirectory multisite installation. */
+		if ( $chunks = explode( '/', $current_blog->path ) ) {
+			foreach( $chunks as $key => $chunk ) {
+				$bkey = array_search( $chunk, $bp_uri );
+				if ( $bkey !== false )
+					unset( $bp_uri[$bkey] );
+				$bp_uri = array_values( $bp_uri );
+			}
+		}
 	}
 
 	/* Set the indexes, these are incresed by one if we are not on a VHOST install */
