404 loops when Polylang is installed

  • Anonymous

    #50163

    404.php loops when Polylang is installed.

    When I replaced get_home_url with get_site_url in wp-content/themes/graphene/404.php,
    the looping stopped.

    I think that the loop occurs because Polylang inserts the language code into the home url.
    This url does not really exist and 404 is repeatedly returned.

    This is the description of get_home_url:

    Retrieves the URL for a given site where the front end is accessible.

    This the description of get_site_url:

    Retrieves the URL for a given site where WordPress application files (e.g. wp-blog-header.php or the wp-admin/ folder) are accessible.

    Maybe you should use get_site_url in 404.php.

    Admin

    Syahir Hakim

    #50229

    Unfortunately using site_url() will cause issues if WordPress is installed on its own directory instead of at the root of the server. Since the automatic search feature is front-facing, home_url() should be used to get the correct URL.

    Anonymous

    #50231

    I have another test environment where the same blog is installed in a subdirectory. My change seems to work there as well.

    I’ve updated to WP 5.0.

    Anonymous

    #50233

    Finally I found the solution. In Polylang settings, enable the following:

    The front page URL contains the language code instead of the page name or page ID
    Example:
    https://my.test.site/en/
    instead of
    https://my.test.site/en/home/

    Now 404 does not loop. No code changes are required.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

Do NOT follow this link or you will be banned from the site!