Make WordPress Core

Opened 8 years ago

Last modified 8 years ago

#3964 closed defect (bug)

Aggressive matching in rewrite.php leads to "nothing matches" errors with custom rewrite endpoints — at Initial Version

Reported by: jhodgdon Owned by: anonymous
Milestone: 2.2 Priority: normal
Severity: normal Version: 2.1.2
Component: General Keywords: rewrite reporter-feedback has-patch 2nd-opinion
Focuses: Cc:


In a plugin, I call add_rewrite_endpoint to add a custom endpoint to the rewrite rules, and then cause a refresh of the rules by calling $wp_rewrite->flush_rules(). I add a suffix endpoint called "foo" to the rewrite rules, for a variety of situations, including post permalinks (in my case, "foo" is actually a language choosing parameter).

My permalink structure is set to /%category%/%postname%/

So, it's working fine on a post, category, page, etc. -- my suffixes are recognized and I can set the language and then find the post. But when I go to the home page and add suffixes, to get a permalink like:


the query fails, because the above it matches the post-with-page-suffix rewrite rule:


and WordPress thinks it is the post in category "foo" with slug "param" (which doesn't exist). Note: I had to type in UC instead of using the up-caret character, to get around WIKI formatting issues.

It's also a problem on feeds, where


matches the same matching rule, and WordPress thinks it is the post in category "feed/foo", with slug "param". That .+ at the beginning of the rule is pretty permissive.

I do have a rule:


but it is farther down in the list than the rule above, and so the rule above takes precidence.

I am not sure how to fix this... any ideas? The API doesn't allow for upping the precedence of rules. For now I have just made my plugin use a GET instead of permalink endpoint for the blog's home page and for feeds, but it is rather annoying.

Change History (0)

Note: See TracTickets for help on using tickets.