• Resolved Andreas

    (@stylingagenten)


    Hi!
    I do have a lot of duplicated URL since Google index all the search parameters as
    ‘?orderby=’, ‘?min_price=’, ‘?filtering=’, ‘?max_price=’, ‘?filter_product_brand=’ , ?rating_filter=

    How can I add noindex for this parameters?

    Thanks!

    Andreas

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

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter Andreas

    (@stylingagenten)

    Hi again. I can also mention that noindex for “Noindex Search Results” is activated. Still the search queries is not taged as noindex. I do use plugins as berocket and Filter Everything PRO. I dont know if your pplugin work with them.

    Thread Starter Andreas

    (@stylingagenten)

    I can also say that the Canonical is set to the origin page, but still Google index the different filter parameters

    Thread Starter Andreas

    (@stylingagenten)

    I did try to add this in my themes child function.php but no success

    // Noindex filter queries
     add_filter( 'rank_math/frontend/robots', function( $robots ) {
    	$url = home_url( $_SERVER['REQUEST_URI'] );
    if (strpos($url,'?filtering=') !== false || strpos($url,'?filter_product_brand=') !== false || strpos($url,'?max_price=') !== false || strpos($url,'?min_price=') !== false || strpos($url,'?orderby=') !== false || strpos($url,'?rating_filter=') !== false) {
      $robots['index'] = "noindex";
    		return $robots;
    };
    	return $robots;
    });
    Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @stylingagenten,

    Thank you for contacting support.

    You have 2 return statements on the function and it should only have one return at the very bottom.

    Also, please make sure to add the nofollow directive as well to the rules like this:

    
    $robots['follow'] = 'nofollow';
    

    If this doesn’t work, we recommend making a test with only Rank Math and the minimum required plugins and see if that works, as this could also be a conflict with other plugins that set robots meta tags on your website.

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

    Thread Starter Andreas

    (@stylingagenten)

    Ok, thanks. Should I add $robots[‘follow’] = ‘nofollow’; as below in the code or in another way?

    // Noindex filter queries
    add_filter( ‘rank_math/frontend/robots’, function( $robots ) {
    $url = home_url( $_SERVER[‘REQUEST_URI’] );
    if (strpos($url,’?filtering=’) !== false || strpos($url,’?filter_product_brand=’) !== false || strpos($url,’?max_price=’) !== false || strpos($url,’?min_price=’) !== false || strpos($url,’?orderby=’) !== false || strpos($url,’?rating_filter=’) !== false) {
    $robots[‘index’] = “noindex”;
    $robots[‘follow’] = ‘nofollow’;
    return $robots;
    };
    return $robots;
    });

    • This reply was modified 2 years, 3 months ago by Andreas.
    • This reply was modified 2 years, 3 months ago by Andreas.
    Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @stylingagenten,

    You’ve added the nofollow code correctly, however, you’ve not yet removed the duplicate return statement.

    Please try the below code:

    // Noindex filter queries
    add_filter( 'rank_math/frontend/robots', function( $robots ) {
    $url = home_url( $_SERVER['REQUEST_URI'] );
    if (strpos($url,'?filtering=') !== false || strpos($url,'?filter_product_brand=') !== false || strpos($url,'?max_price=') !== false || strpos($url,'?min_price=') !== false || strpos($url,'?orderby=') !== false || strpos($url,'?rating_filter=') !== false) {
    $robots['index'] = "noindex";
    $robots['follow'] = 'nofollow';
    };
    return $robots;
    });

    Let us know how that goes.

    Hi. I have a similar issue to the above so just want to make sure the code I am adding is relevant to my site and the URL strong.

    Below is the URL string when a filter is applied to a page:

    https://www.webiste.com/hardware/?min_price=150&max_price=200&filter_finish=dark-bronze&tax_product_cat=cabinet&filter_size=128mm&unfilter=1

    I have added the following code to my Theme functions.php file:

    // Noindex filter queries
    add_filter( 'rank_math/frontend/robots', function( $robots ) {
    	$url = home_url( $_SERVER['REQUEST_URI'] );
    	if (strpos($url,'?min_price=') !== false || strpos($url,'?max_price=') !== false || strpos($url,'?filter_finish=') !== false || strpos($url,'?tax_product_cat=') !== false || strpos($url,'?filter_size=') !== false || strpos($url,'?filter_backset-size=') !== false) {
    	$robots['index'] = "noindex";
    	$robots['follow'] = 'nofollow';
    	};
    	return $robots;
    	});

    Is this correct and the Filter page URLs will no longer be indexed by Search Engines?

    Many thanks, Jamie

    Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @dzzstudio,

    Yes, the filter you have shared seems correct for your site. Please apply it to your site and let us know if you need any other assistance.

    We are here to assist.

    Also, please do open a new support topic if you need any further assistance.

    Thank you.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Noindex for search filter in URL’ is closed to new replies.