• Resolved Pat K

    (@blackcapdesign)


    This looks like a great way to block pesky and malicious bots – thanks for sharing your plugin!

    I have a few other plugins that dynamically add code to the generated robots.txt file and I didn’t see any instructions for adding the required blackhole rule dynamically (only instructions for creating the file manually). So for anyone wishing to add the blackhole rule dynamically, adding this code snippet to the functions.php file in the site’s child theme worked for me:

    // Add Blackhole for Bad Bots Rule to generated robots.txt file 
    add_filter('robots_txt', 'machine_robots', 10, 2 );
    function machine_robots( $output, $public ) {
      $output .= "Disallow: /?blackhole";
      return $output;
    }

    I will post a follow up if this causes any problems…

    pk

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Adding Blackhole Rule to Generated robots.txt file’ is closed to new replies.