• Resolved Pascal Birchler

    (@swissspidy)


    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 at example.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
Viewing 7 replies - 16 through 22 (of 22 total)
  • Jirsbek

    (@jirsbek)

    @cedriccharles Well eventually for me either… I’ve realized problem occurred in some cases even with the latest version of Polylang after the WordPress update. Only thing helped was flushing the permalinks so now I’m quite afraid it will happen again without me knowing it.

    Ced

    (@cedriccharles)

    ??

    artiemart

    (@artiemart)

    Using 3.5.4 PRO we still have this problem.

    Saving the URL settings without having made changes reproduces the problem. (Page 404).
    Here is an example of the rewrite rules before.
    [(fr|nl|en)/research/([^/]+)/comment-page-([0-9]{1,})/?$] => index.php?lang=$matches[1]&research=$matches[2]&cpage=$matches[3]
    And this is after.
    [research/([^/]+)/comment-page-([0-9]{1,})/?$] => index.php?research=$matches[1]&cpage=$matches[2]
    Saving premalinks repairs the problem.
    Is there any news on this?

    Ced

    (@cedriccharles)

    @artiemart, @jirsbek, @swissspidy,

    Have you found something? I’m still getting the 404 error sometimes… ??

    @cedriccharles No luck ?? Just in case I’ve setup monitoring of specific keyword on /admin/ page on websites using Polylang I manage so I’ll get a notification, when this admin is not actually admin thus problem probably occurs there so I can quickly react.

    Ced

    (@cedriccharles)

    So basically, when you /admin/ page is 404, you’re notified and you go flushing rewrite rules?

    Well in my case single post and /admin/ URL shows index.php even though homepage is actually using specific template and index.php in my theme folder is empty. So on login page I’m monitoring link “Did you forget your password” or similar and if it’s not present something is wrong. But to be honest this happened only once since I set the monitoring up.

Viewing 7 replies - 16 through 22 (of 22 total)
  • The topic ‘Conflicting rewrite rules breaking single posts’ is closed to new replies.