Index: wp-includes/rewrite.php
===================================================================
--- wp-includes/rewrite.php	(revision 5058)
+++ wp-includes/rewrite.php	(working copy)
@@ -582,6 +582,16 @@
 			if ($paged) //...and /page/xx ones
 				$rewrite = array_merge($rewrite, array($pagematch => $pagequery));
 
+			//do endpoints
+			if ($endpoints) {
+				foreach ($ep_query_append as $regex => $ep) {
+					//add the endpoints on if the mask fits
+					if ($ep[0] & $ep_mask || $ep[0] & $ep_mask_specific) {
+						$rewrite[$match . $regex] = $index . '?' . $query . $ep[1] . $this->preg_index($num_toks + 2);
+					}
+				}
+			}
+
 			//if we've got some tags in this dir
 			if ($num_toks) {
 				$post = false;
@@ -599,16 +609,6 @@
 						$page = true;
 				}
 
-				//do endpoints
-				if ($endpoints) {
-					foreach ($ep_query_append as $regex => $ep) {
-						//add the endpoints on if the mask fits
-						if ($ep[0] & $ep_mask || $ep[0] & $ep_mask_specific) {
-							$rewrite[$match . $regex] = $index . '?' . $query . $ep[1] . $this->preg_index($num_toks + 2);
-						}
-					}
-				}
-
 				//if we're creating rules for a permalink, do all the endpoints like attachments etc
 				if ($post) {
 					$post = true;
