How to change “index” meta tag robots in a 404 page

#438021
  • Resolved Stefania Cosma
    Rank Math free

    Hello, in my website all my Error pages (404) are now indexed, as their meta tag robots is set as “nofollow, index”. I want to change this setting and set the meta tag robots for 404 pages as “nofollow, noindex”. How can I do it?

    Thank you in advance for your help

    kind regards

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello,

    Thank you for contacting Rank Math support, and sorry for any inconvenience that might have been caused due to that.

    Typically, Rank Math automatically sets 404 pages to noindex. Can you please confirm if this 404 page is a templated page from your theme?

    You may share your website URL with us here so we can further check.

    Also, you may follow this filter to forcibly mark the robots meta as noindex:

    add_filter( 'rank_math/frontend/robots', function( $robots ) {
      $url = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
      if($url == 'TARGET_URL') {
        $robots["index"] = 'noindex';
        $robots["follow"] = 'nofollow';
      }
      return $robots;
    });

    Looking forward to helping you on this one.

    Hello, thank you for your answer.

    Where should I put that code filter?

    My website is: http://www.stefanocassaro.com

    I thank you in advance if you can help me to fix this problem,

    Kind regards

    Anas
    Rank Math business

    Hello,

    You can add the filter to your theme’s functions.php file.

    Here is a guide you can follow to add the filter:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/#functions-php-file

    However, I checked a 404 page on your website and it is already set to noindex.
    noindexed

    Hope this helps.

    Don’t hesitate to get in touch if you have any other questions.

    Thank you!

    Anas
    Rank Math business

    Hello,

    We are glad we could address your concern. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

Viewing 5 replies - 1 through 5 (of 5 total)

The ticket ‘How to change “index” meta tag robots in a 404 page’ is closed to new replies.