Automated search starts looping

  • Anonymous


    Graphene 2.5.2.
    Local environment with Php 7.2.10.

    Automated search starts looping when page not found (404).

    How can I upload a screenshot or part of the access log?




    I have the following folder structure:

    WP is installed into the document root.
    I have a static welcome page containg two buttons:

    1. to the blog
    2. to the webshop (which resides in the subfolder “/shop”

    If 404 occurs in the webshop application, Graphene and/or WP notices this, even if it’s not related to WP at all. Is there a way to disable automated search in a subfolder?



    I added error_log($redirect_location);
    into Graphene’s 404.php.

    Polylang is also installed and in use.

    This is the output after cancelling the request:

    [09-Dec-2018 17:00:29 UTC]
    [09-Dec-2018 17:00:32 UTC]
    [09-Dec-2018 17:00:35 UTC]
    [09-Dec-2018 17:00:37 UTC]



    I switched to Twenty Nineteen Theme. No loop.

    After switching back to Graphene, the automated search started looping again.

    So, this seems to be Graphene issue.



    When I replaced the following line in wp-content/themes/graphene/404.php:

    $redirect_location = get_home_url() . ‘?s=’.$search_term_q.’&search_404=1′;
    $redirect_location = get_site_url() . ‘?s=’.$search_term_q.’&search_404=1′;

    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.



    I exluded the subfolder “shop” from WordPress by using this .htaccess:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !^/shop
    RewriteRule . /index.php [L]

    The automated search does not anymore apply to the subfolder “shop”.



    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
    instead of

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

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

  • You must be logged in to reply to this topic.