Conflicting rewrite rules breaking single posts
-
I keep running into an issue with Polylang’s rewrite rules as they break my any singular post requests because WP ends up thinking it’s on the home page. This happens every time I save the Polylang settings, and I can fix it by flushing my permalinks again.
I use the following URL layout in Polylang:
The language is set from the directory name in pretty permalinks
Hide URL language information for default language
Remove /language/ in pretty permalinks
So in other words, my default language (EN) blog posts will be at
example.com/hello-world/
and other (e.g. DE) blog posts will be atexample.com/de/hallo-welt/
.This used to work fine in the past, but I don’t know what’s different on this site, so I figured in addition to debugging myself I’m gonna seek help here as well.
The problem is now when I visit
example.com/hello-world/
, WordPress matches the([^/]+)/?$ -> lang=$matches[1]
rewrite rule, when in fact it should match(.?.+?)(?:/([0-9]+))?/?$ -> pagename=$matches[1]
&page=$matches[2]You can see this on these screenshots with Query Monitor:
Bad:
Good:
See the difference in rewrite rules.
Some additional information:
- I’m using WordPress 6.4.1 on PHP 8.2
- Other notable plugins include Site Kit, Jetpack, Yoast SEO
- I’m an advanced user / developer so happy to cut to the chase and do some more hands-on debugging if needed
- The topic ‘Conflicting rewrite rules breaking single posts’ is closed to new replies.