NoFollow not working

#939833
  • Resolved S R
    Rank Math free

    Hello,

    I keep getting dynamic cart.php 404 errors on my google search console. Since then I put my /cart/ page as noindex. Still got more errors. After that I set it as noindex, nofollow, noimages, everything no. I clear cache, inspect the cart page and it is set to noindex, follow.

    No matter what I do, even with custom code, it keeps showing up as noindex, follow. So google is following these dynamic links which has caused hundreds of 404 errors I cannot get rid of. Why doesn’t it work and what is the solution here? Thank you.

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

    Thank you for contacting support.

    Please share the exact report/error you are getting from the Google Search Console with us.

    You can share screenshots using this tool: https://imgur.com/upload

    We look forward to helping you.

    Thanks.

    S R
    Rank Math free

    There is no report error. I do not understand what you mean. You seem not to be understanding me. What I am saying is that I set the cart page to Noindex, Nofollow using rankmath, but when I inspect the page, it shows Noindex, Follow. Therefore the “NoFollow” is not being applied.

    I already sent you the line of how it is showing up. This:

    <meta name=”robots” content=”noindex, follow”>

    When I should be seeing this:

    <meta name=”robots” content=”noindex, nofollow”>

    Why is it not applying the NoFollow directive?

    Hello,

    You can add the following filter on the website to set the URLs with the string cart to noindex:

    add_filter( 'rank_math/frontend/robots', function( $robots ) {
        // Get the current page URL
        $current_url = home_url( $_SERVER['REQUEST_URI'] );
        
        // Define the string to check for in the URL
        $string_to_check = 'cart';
        
        // Check if the current URL contains the specific string
        if ( strpos( $current_url, $string_to_check ) !== false ) {
            // Change the robots tag to noindex
            $robots['index'] = 'noindex';
            $robots['follow'] = 'nofollow';
        }
        
        // Return the modified robots array
        return $robots;
    });

    Here’s how you can add filter/hook to your WordPress site: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    We hope this helps.

    Thanks.

    S R
    Rank Math free

    Using Code Snippets Plugin which I use for everything else, added the code to be applied everywhere, cleared cache and viewed source code on incognito window and no change.

    Hello,

    Could you please share a sample URL in the sensitive data section so we can check as well?

    Meanwhile, please try this filter if it sets the URL to noindex and nofollow:

    add_filter( 'rank_math/frontend/robots', function( $robots ) {
    	if( is_cart() ) {
    		$robots['index'] = 'noindex';
                    $robots['follow'] = 'nofollow';
    	}
    	return $robots;
    }, 99);

    Looking forward to helping you.

    S R
    Rank Math free

    This code works. Thank you so much.

    Hello,

    We are glad to be of help

    Do you still need our assistance with anything else or can we go ahead to close the ticket?

    We look forward to helping you.

    Thank you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

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

The ticket ‘NoFollow not working’ is closed to new replies.