• Resolved Bastbra

    (@comicschau)


    Hi,

    so my problem is that Google indexed a lot of canonical URLs, that it should not index. An example:

    When the site is example.com/example/, it also adds example.com/example/?amp and example.com/example/?quad_cc

    Weird thing is, I can’t get it away and I don’t even use any AMP plugin or Quadmenu, I may have used this in the past, but not now anymore. These URLs keep being in the Google Search Console list and I can’t get them out there. Is there any way to redirect just those things after /? or something? Of course without conflicting with search on the site.

    Do you know what is causing this and how to fix it with Rank Math?

    It would be highly appreciated, been using your plugin for a long time now.

    Best regards!

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

    (@rankmathteam)

    Hello @comicschau,

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

    You can handle those in two ways. Either way, you can disallow those URLs with a query parameter in your robots.txt file to prevent search engine bots from crawling them. Here’s an example of how they should look like:
    User-agent: * Disallow: */?quad_cc Disallow: */?amp

    Here’s how you can edit the robots.txt file using Rank Math:
    https://rankmath.com/kb/add-sitemaps-to-robots-txt/#num-2-2-navigate-to-edit-robots-txt

    Or, you may use the following filter to set noindex to those URLs with specific query parameters:
    add_filter( 'rank_math/frontend/robots', function( $robots ) { $url = home_url( $_SERVER['REQUEST_URI'] ); if( (strpos($url,"?quad_cc") !== false) || (strpos($url,"?amp") !== false) ) { $robots["index"] = 'noindex'; $robots["follow"] = 'nofollow'; } return $robots; });

    The filter shared above, will set noindex robots meta directive to all the URLs that contain ?quad_cc and ?amp.

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

    If those URLs are already indexed on SERPs, we’d recommend following the second method to get rid of them from SERPs.

    Hope that helps, and please do not hesitate to let us know if you need our assistance with anything else.

    Thread Starter Bastbra

    (@comicschau)

    Thanks a lot! Did that.

    And if I generally want to get rid of the /? in search results, should I just add “?” without something behind it? Most of the wrong results are with ?amp and ?quad_cc, but a few are also with different things behind this.

    Best regards!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Google is indexing canoncial URLs, even if it should not’ is closed to new replies.