How to stop indexing dynamics URLs through filters

#444794
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for any inconvenience this issue may have caused you.

    I’ve checked your dynamic filter pages, and it seems that they are set to index.

    In this case, I’ve added this filter to set them to noindex at the last line of your theme’s functions.php:

    // Noindex filter queries
    add_filter( 'rank_math/frontend/robots', function( $robots ) {
    $url = home_url( $_SERVER['REQUEST_URI'] );
    if (strpos($url,'?product_orderby=') !== false || strpos($url,'?product_view=') !== false || strpos($url,'?product_count=') !== false || strpos($url,'?product_order=') !== false ) {
    $robots['index'] = "noindex";
    $robots['follow'] = 'nofollow';
    };
    return $robots;
    });

    You can validate the error in your Google Search Console account for that URLs and give Google some time to recrawl your site.

    I hope that helps.

    Thank you.

    Thank you I will validate this issue in Google Search Console now 🙂
    Regards

    Hello,

    Glad that helped.

    Please feel free to reach out to us again in case you need any other assistance.

    We are here to help.

    Thank you.

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

You must be logged in to reply to this ticket.