- foreach ( (array) $rewrite as $match => $query) {
- // Don't try to match against AtomPub calls
- if ( $req_uri == 'wp-app.php' )
- break;
-
- // If the requesting file is the anchor of the match, prepend it
- // to the path info.
- if ( (! empty($req_uri)) && (strpos($match, $req_uri) === 0) && ($req_uri != $request) )
- $request_match = $req_uri . '/' . $request;
-
- if ( preg_match("#^$match#", $request_match, $matches) ||
- preg_match("#^$match#", urldecode($request_match), $matches) ) {
- // Got a match.
- $this->matched_rule = $match;
-
- // Trim the query of everything up to the '?'.
- $query = preg_replace("!^.+\?!", '', $query);
+ if ( empty( $request_match ) ) {
+ // An empty request could only match against ^$ regex
+ if ( isset( $rewrite['$'] ) ) {
+ $this->matched_rule = '$';
+ $query = $rewrite['$'];
+ $matches = array('');
+ }
+ } else {
+ foreach ( (array) $rewrite as $match => $query ) {
+ // If the requesting file is the anchor of the match, prepend it to the path info.
+ if ( ! empty($req_uri) && strpos($match, $req_uri) === 0 && $req_uri != $request )
+ $request_match = $req_uri . '/' . $request;
+
+ if ( preg_match("#^$match#", $request_match, $matches) ||
+ preg_match("#^$match#", urldecode($request_match), $matches) ) {
+
+ if ( $wp_rewrite->use_verbose_page_rules && preg_match( '/pagename=\$matches\[([0-9]+)\]/', $query, $varmatch ) ) {
+ // This is a verbose page match, let's check to be sure about it.
+ $page = get_page_by_path( $matches[ $varmatch[1] ] );
+ if ( ! $page ) {
+ continue;
+ }
+
+ $post_status_obj = get_post_status_object( $page->post_status );
+ if ( ! $post_status_obj->public && ! $post_status_obj->protected
+ && ! $post_status_obj->private && $post_status_obj->exclude_from_search ) {
+ continue;
+ }
+ }