Installing Blackhole for Bad Bots
- 01Upload the Blackhole plugin to your blog and activate
- 02Visit the Blackhole Settings and copy the Robots Rules
- 03Add the Robots Rules to your site’s robots.txt file (see note)*
- 04Configure the Blackhole Settings as desired and done
Note: For the robots.txt rules, there are two scenarios:
- 05Your site has a physical robots.txt file that you can see on the server. In this case, you need to add the required rules manually.
- 06OR, your site is using the dynamic/virtual WP-generated robots.txt file, and there is no physical robots.txt file on your server. In this case, the plugin adds the required rules automatically. You do not need to add anything manually.
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
Verify Blackhole is working properly
Caching Plugins
Important: Do NOT use this plugin on sites with caching. Learn more »
No robots.txt?
For the robots.txt file, there are two possible scenarios:
- 07You want to use your own physical robots.txt file that you can view and edit on the server. In this case, follow the steps below to create your site’s robots.txt file.
- 08OR, you want to use the dynamic/virtual WP-generated robots.txt file, such that there is no physical robots.txt file on your server. In this case, you don’t need to do anything, because WordPress automatically generates a robots.txt file when requested.
If you go with option #1, here are the steps to create a robots.txt file for your site:
- 09Add a blank plain-text file to the root directory of your site
- 10Name the text file robots.txt and upload to your server
Done. Now you can add the Blackhole rules provided on the plugin settings page. See the next section to learn more and validate your robots.txt file.
To view your robots.txt file, visit the following URL (replace example.com with your domain):
https://example.com/robots.txt
Tip: you can find a link to your site’s robots.txt file on the plugin settings page.
Robots Tools & Info
Here are some collected resources for working with robots.txt. See also the next section, “Testing Robots.txt” for more tools.
- 11Learn more about robots.txt
- 12Validate your robots.txt file
- 13Validate robots.txt in Google Webmaster Tools
- 14Google Robots.txt Specifications
- 15How to Create a robots.txt file
Lots more great resources on the web to learn about and validate your robots.txt file. Read up, it’s important for SEO.
Testing Robots.txt
To test that your site’s robots.txt rules are correct, you can use a free robots.txt checker. Google provides a robots checker inside of your Google account (i.e., must be logged in to Google). There are many other robots validators around online. Here are some examples:
- 16Robots.txt Validator
- 17Robots.txt Checker
- 18Robots.txt Test
Tons more robots tools available online, just search for something like “validate robots.txt” (without the quotes) to discover more.
Testing Blackhole
To test that the Blackhole trap is working, first remove your IP address(es) from the plugin setting, “Whitelist IPs”. Also make sure your browser is not included in the plugin setting, “Whitelist Bots” (for example, Chrome is whitelisted). OR instead of changing any plugin settings, you can use a proxy service and non-whitelisted browser (e.g., Brave or Opera) to perform the test.
After removing your IP address and user agent (or using a proxy service), 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="Do NOT follow this link or you will be banned from the site!">Name of Your Website</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.
More information on how to verify Blackhole is working »
Why no bots?
If you’re not seeing any bad bots getting blocked, there are several things to keep in mind:
- 19Make sure you’ve set up according to the docs above
- 20New(er) websites may not get a lot of bad bot traffic
- 21Sites with low traffic may not get a lot of bad bots
- 22Check if you are using any other bot-blocking plugins
- 23Not all websites (even popular ones) get tons of bots
- 24Blackhole will not work if you have any caching on site
- 25If in doubt, you can test if the plugin is working (see previous section above)
So keep those things in mind. In most cases it’s just a matter of time before some bad bots fall into the black hole.
Also note that the plugin provides two “whitelist” settings:
- 26Whitelist Bots
- 27Whitelist IPs
By default, certain things are automatically whitelisted when the plugin is activated. For example, your IP address is added to the whitelist IP setting. Also Chrome and other user agents are added to the whitelist user-agents setting. Just to keep in mind when testing plugin functionality.
Whitelisted Bots
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.
adsbot-google, ahrefsbot, apis-google, baidu, bingbot, bingpreview, cloudflare, duckduckgo, embedly, facebookexternalhit, facebot, google page speed, googlebot, ia_archiver, linkedinbot, mediapartners-google, msnbot, pinterest, rogerbot, slackbot, slurp, teoma, twitterbot, uptimerobot, urlresolver, w3c_validator, wordpress, wp rocket, 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, “Whitelist 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:
123.456.
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.
Customizing
Blackhole provides plenty of hooks for customizing and extending:
blackhole_options blackhole_badbots blackhole_get_options blackhole_get_badbots blackhole_log_data blackhole_trigger blackhole_vars blackhole_log blackhole_ip_keys blackhole_alert_name blackhole_alert_subject blackhole_alert_message blackhole_alert_headers blackhole_needle blackhole_message_default blackhole_message_custom blackhole_message_nothing blackhole_ignore_loggedin blackhole_ignore_backend blackhole_ignore_login blackhole_block_status blackhole_block_protocol blackhole_block_connection blackhole_ip_filter blackhole_validate_ip_log blackhole_settings_contextual_help blackhole_badbots_contextual_help
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:
- 28Warning Message – Displayed when bots follow the blackhole trigger
- 29Blocked 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:
- 30Copy blackhole-template.php from the plugin’s /inc/ directory
- 31Paste the file into your theme template, for example: /wp-content/my-awesome-theme/blackhole-template.php
- 32Customize any of the markup between “BEGIN TEMPLATE” and “END TEMPLATE”
- 33Upload 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.
Tip: Instead of including the custom template in your theme, you can include via /wp-content/ directory, like: /wp-content/blackhole/blackhole-template.php
More options available in the Pro version »
Uninstalling
This plugin cleans up after itself. All plugin settings and collected data will be removed from the WordPress database when the plugin is deleted via the WP 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 uninstall.php :
delete_option('bbb_options'); delete_option('bbb_badbots');
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!