no index by url

#442565
  • Resolved Tasos
    Rank Math free

    Hello. Is there an option in Rankmath to noindex auto-translated urls (e.g apply noindex tag to all the urls that contain /en/) and not apply this also on the main page. E.g i got example.com and example.com/en. I want the noindex tag to be applied on the /en url and not the simple one. I tried adding noindex and it is applied to both urls. Im using translatepress plugin.

    This may be a nice feature for your plugin also.

    Thanks in advance.

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

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

    In this case, you would need to apply a filter for these specific URLs. Please refer to this code here:

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

    Here’s our guide with regards to applying our filter to your website:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/

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

    Tasos
    Rank Math free

    Your response was fast and life-saving. Thank you very much as it has solved my problem. I marked the topic as closed. Just fyi i searched google a lot but didn’t find a specific way to do this until now. Thanks again.

    Hello,

    We are super happy that this resolved your issue. 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 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this ticket.