• Resolved chingiz35

    (@chingiz35)


    Hello! Please tell me how to prohibit yoast from adding rules to robots.txt . I have a plugin that automatically puts subdomains for a file robots.txt and the side is somehow inserted into this file
    # START YOAST BLOCK
    # —————————
    User-agent: *
    Disallow:

    Sitemap: https://metallkom96.ru/sitemap_index.xml
    # —————————
    # END YOAST BLOCK
    how to prohibit the insertion of this block?`

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Phillip van Wyk

    (@ottartheboar)

    @chingiz35 I’m having a similar issue and coded this filter as a temporary workaround.

    
    function remove_yoast_seo_robots_block( $output, $public ) {
    	return preg_replace('/'.preg_quote('# START YOAST BLOCK').'[\s\S]+?'.preg_quote('# END YOAST BLOCK').'/', '', $output);
    }
    add_filter( 'robots_txt', 'remove_yoast_seo_robots_block', 999999, 2 );
    

    This filter removes the whole block inserted by the Yoast SEO plugin. It’s essential to set the filter priority to something above 9999 to ensure the filter executes after Yoast SEO has inserted the block.

    Thread Starter chingiz35

    (@chingiz35)

    Hello! Phillip, thanks, it worked for me!

    Thread Starter chingiz35

    (@chingiz35)

    I want to raise this issue again. For a moment the problem disappeared, but then it came back again. Dear YOAST tech support how to get rid of this output. I would like only my entries to work in robots.txt . Without interference

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘how to prevent yoast from adding rules to robots.txt?’ is closed to new replies.