Aggressive matching in rewrite.php leads to "nothing matches" errors with custom rewrite endpoints
|Reported by:||jhodgdon||Owned by:||westi|
|Component:||General||Keywords:||rewrite reporter-feedback has-patch 2nd-opinion|
Description (last modified by westi)
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).
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 (22)
- Component changed from Administration to General
- Priority changed from low to normal
- Version set to 2.1.2
- Owner changed from anonymous to westi
- Status changed from new to assigned