Support » Plugin: Rank Math - Best SEO Plugin for WordPress » 404 Logs Not Coming

  • Resolved marcopolo11

    (@marcopolo11)


    I have installed rankmath on my website durvient.com and have a custom page for 404 page for visitor’s redirection. I have also turned on 404 monitor in rankmath however 404 logs are not popping up despite visitors are reporting 404 page popping up.

    What might be wrong?

    The page I need help with: [log in to see the link]

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @marcopolo11,

    Thank you for contacting the support.

    Our plugin doesn’t detect the 404s when using a custom template. You will have to modify the code at line 230 in wp-content\plugins\seo-by-rank-math\includes\modules\404-monitor\class-monitor.php to look like this:

    else {
    return 'template_redirect';
    }

    Once done, the 404 monitor should be able to log the 404s.

    Hope this helps.

    Thread Starter marcopolo11

    (@marcopolo11)

    Hi Team,

    Added the code in line 231 (230 is occupied with code), hope that’s fine.

    I tried a couple of 404 urls but log still didn’t build up.

    Here is the snippet of how the code looks like

    https://snipboard.io/mkubGM.jpg

    Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @marcopolo11,

    Please edit the same file i.e, /seo-by-rank-math/includes/modules/404-monitor/class-monitor.php.

    On line 46, change this:
    $hook = defined( 'CT_VERSION' ) ? 'oxygen_enqueue_frontend_scripts' : 'get_header';

    To this:
    $hook = defined( 'CT_VERSION' ) ? 'oxygen_enqueue_frontend_scripts' : 'template_redirect';

    Once done, clear your website’s cache and access any 404 URL on your website and see if it gets logged in the 404 Monitor.

    Let us know how that goes. Thank you.

    Thread Starter marcopolo11

    (@marcopolo11)

    Apologies but it appears the lines you are quoting and I am seeing are completely different. I could not find the said code on the line 46 however there is similar on the line 227.

    How can I share the php file I have on my site with you?

    Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @marcopolo11,

    We’re sorry for the confusion. We have updated that section of the plugin in one of our recent updates and the lines have changed as you correctly mentioned.

    However, could you confirm which theme you’re using and also, if your custom 404 page is generated by the theme or some plugin/page builder?

    Looking forward to helping you.

    Thread Starter marcopolo11

    (@marcopolo11)

    Our site is on woodmart theme, the 404 page is manually created (content provided by the theme).

    Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @marcopolo11,

    Please add the code given below at line 230 in wp-content\plugins\seo-by-rank-math\includes\modules\404-monitor\class-monitor.php:

    else {
    return 'template_redirect';
    }

    This will fix the issue. Let us know if it doesn’t. We are here to assist.

    Thread Starter marcopolo11

    (@marcopolo11)

    I have added the lines, have tried triggering a couple of 404 but log does not appear. I will monitor it for some more time and then report back.

    Have added it on 231 instead of 230 as 230 is already occupied by another line of code.

    Kindly review it here:
    https://snipboard.io/ls6Cyf.jpg

    Thread Starter marcopolo11

    (@marcopolo11)

    By the way, the above solution was provided 2 weeks ago as well but it didn’t work, not sure how can the same line of code do magic now.

    Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @marcopolo11,

    We had a closer look at the 404 page on your website and we noticed two issues:
    1. 404 URLs are redirected to the 404 page instead of returning a 404 status on the same URL.
    2. The 404 page itself is returning a 200 (OK) status instead of a 404 status. Here’s a screenshot for a quick reference: https://i.rankmath.com/okodk6

    We use the is_404 condition of WordPress to detect the 404 page. If this condition returns false on a custom 404 page then the page will not get logged in the 404 Monitor.

    Please get in touch with your theme developers regarding this and also mention the above issues with them. They should be able to help you fix the issue.

    Hope this helps.

Viewing 10 replies - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.