Installing Blackhole for Bad Bots
- Upload the Blackhole plugin to your blog and activate
- Visit the Blackhole Settings and copy the Robots Rules
- Add the Robots Rules to your site’s robots.txt file
- Configure the Blackhole Settings as desired and done
For complete documentation, click the “Help” tab in the upper-right corner of the Blackhole settings screen. Help tab also available on the “Bad Bots” screen.
More info on installing WP plugins
If your site does not have a robots.txt file, you can create one as follows:
- Add a blank text file to the root directory of your site
- Name the text file, robots.txt and upload to your server
Done. See the next section to learn more and validate your robots.txt file.
Robots Tools & Info
Blackhole works with any type of caching plugin where “page caching” is not enabled.
There are many types of cache plugins. They provide all sorts of different caching mechanisms and features. All caching features work great with Blackhole except for “page caching”. With page caching, the required WP
init hook may not be fired, which means that plugins like Blackhole are not able to log and ban requests dynamically. Fortunately, some of the most popular caching plugins provide settings that enable full compatibility with Blackhole. For a complete list, check out this article. Note: that article was written for Blackhole Pro, but the compatibility list and general info apply also to Blackhole (free version).
To test that the Blackhole trap is working, view the source code of any web page on your site. Scroll down near the footer of the page until you locate a link that looks similar to the following:
<a rel="nofollow" style="display:none;" href="https://example.com/?blackhole=1234567890" title="Blackhole for Bad Bots">Do NOT follow this link or you will be banned from the site!</a>
Click the link (the
href value) to view the Warning Message. After visiting the Warning Message, refresh the page to view the Access Denied message. And/or visit any other page on the front-end of your site to verify that you have been banned. But don’t worry, you will never be banned from the WP Admin Area or the WP Login Page. So simply log in and remove your IP address from the Bad Bots list to restore front-end access.
Blackhole for Bad Bots is rigorously tested to ensure that the top search engine bots are NEVER BLOCKED. Any bots reporting a User Agent that contains any of the following strings will always have access to your site, even if they disobey robots.txt.
aolbuild, baidu, bingbot, bingpreview, msnbot, duckduckgo, adsbot-google, googlebot, mediapartners-google, teoma, slurp, yandex
Of course, this list is completely customizable via the plugin settings. Each added string is matched against the full user agent, so be careful. Learn more about user agents of the top search engines.
You can also whitelist bots by IP address. Visit the setting, “Whitelisted IPs”, and enter the IP address (separate multiple IPs with commas). You can also whitelist entire ranges of IPs. In the same plugin setting, add something like this:
That will allow all bots reporting any IP that begins with
123.456.. You can also whitelist IP addresses using CIDR notation. Check out the Help tab on the plugin settings page for details.
Blackhole provides plenty of hooks for customizing and extending:
If you need a hook added, drop me a line, will be glad to hook it up 😉
Custom Warning Template
The Blackhole displays two types of messages:
- Warning Message – Displayed when bots follow the blackhole trigger link
- Blocked Message – Displayed for all requests made by blocked bots
The Blocked Message may be customized via the plugin settings. The Warning Message may be customized by setting up a custom template:
blackhole-template.php from the plugin’s
- Paste the file into your theme template, for example:
- Customize any of the markup between “BEGIN TEMPLATE” and “END TEMPLATE”
- Upload to your server and done
If the custom template exists in your theme directory, the plugin automatically will use it to display the Warning Message. If the custom template does not exist in your theme directory, the plugin will fallback to the default warning message.
More options available in the Pro version »
Blackhole for Bad Bots cleans up after itself. All plugin settings and the bad bot list will be removed from your database when the plugin is uninstalled via the Plugins screen. After uninstalling, don’t forget to remove the blackhole rules from your
robots.txt file. It’s fine to leave them in place, it will not hurt anything, but they serve no purpose without the plugin installed.
More specifically, Blackhole adds only two things to the database: options and bot list. When the plugin is uninstalled/deleted via the Plugins screen, both of those items are removed automatically via the following lines in
So after uninstalling the plugin and deleting the robots.txt rules, there will be no trace of Blackhole for Bad Bots on your site.
Like the plugin?
If you like Blackhole for Bad Bots, please take a moment to give a 5-star rating. It helps to keep development and support going strong. Thank you!