Automated search starts looping

  • veltsu

    #50151

    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?

    veltsu

    #50156

    Anyone?

    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?

    veltsu

    #50157

    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] https://my.test.site/en/home?s=foo&search_404=1
    [09-Dec-2018 17:00:32 UTC] https://my.test.site/en/home?s=%3Fs%3Dfoo%26search+404%3D1&search_404=1
    [09-Dec-2018 17:00:35 UTC] https://my.test.site/en/home?s=%3Fs%3D%3Fs%3Dfoo%26search+404%3D1%26search+404%3D1&search_404=1
    [09-Dec-2018 17:00:37 UTC] https://my.test.site/en/home?s=%3Fs%3D%3Fs%3D%3Fs%3Dfoo%26search+404%3D1%26search+404%3D1%26search+404%3D1&search_404=1

    veltsu

    #50161

    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.

    veltsu

    #50162

    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′;
    with
    $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.

    veltsu

    #50164

    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]
    </IfModule>

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

    veltsu

    #50234

    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 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.