Not all bots are harmful: search engine crawlers need access to pages to discover and index them, and SEO services use their own bots to collect data. But unwanted automated traffic can skew analytics, consume data transfer allowances and be accompanied by attempts to attack the site.
The choice of restriction method depends on the task. Asking a well-behaved bot not to crawl a section is one thing; protecting a site from a program that ignores such instructions is another.
What bots are and how they differ
A bot is a program that performs specific tasks automatically and repeatedly. In SEO, bots help scale work, for example by collecting search results data and automating repetitive tasks. Semrush and Ahrefs are among the services that use their own bots.
Malicious bots can look for vulnerabilities, attempt to steal data, post unwanted links or send spam through forms. Botnets are also used for distributed denial-of-service (DDoS) attacks. Blocking all bots indiscriminately, however, can interfere with useful services and search engines.
When to limit access
One reason is to protect site data and functionality. For example, automated requests may be associated with attempts to exploit a plugin vulnerability, modify page content or send spam through a contact form. In such cases, you need not only to restrict access for suspicious clients but also to check the security of the site itself.
Another reason is data transfer costs. When request volumes are high, bots can consume the traffic allowance included in your plan and lead to additional charges. Check the terms and limits in your agreement with your hosting provider.
Automated traffic can also make it harder to analyze traffic sources and lead to incorrect attribution in analytics systems. Before introducing restrictions, it is useful to identify which requests are causing the problem: detecting every bot that visits a site is not easy.
Restrictions via robots.txt
The robots.txt file is placed in the site's root directory and contains instructions for search engine crawlers and other bots. It can specify a rule for a particular user-agent or for all bots, along with a path they should not crawl.
For example, a Googlebot rule that disallows the root path asks Google's crawler not to crawl the entire site. This restriction should not be introduced accidentally: it can prevent the search engine from accessing page content. The source material gives a test version of a site as a possible use case, when its owner does not want search engine crawlers to see it alongside the main site.
Similarly, you can direct a disallow rule at all bots or specify a particular folder instead of the root. The latter option is used, for example, to prevent crawling of a section with duplicate content.
However, robots.txt is not a way to protect a confidential site: its instructions depend on whether the bot follows them. A crawl restriction also does not, by itself, guarantee that a URL will not appear in the search index.
Common robots.txt mistakes
Before changing the file, it is important to check the exact user-agent name and path. A mistake in the name may mean that the rule does not affect the intended bot, while an inaccurate path may leave the intended section unrestricted. The completed file should be tested.
Be especially careful when disallowing the root path: a forward slash as the path applies the rule to the entire site, even if its author intended to block only a specific URL.
Another mistake is to disallow crawling of a page in robots.txt while also placing a noindex directive on it. As Google representative John Mueller noted, in that case Google cannot crawl the page and see the noindex directive, yet the URL may still be indexed. The choice between restricting crawling and preventing indexing should therefore match the specific task.
Restricting SEO service bots
Site owners sometimes restrict access for competitive SEO analysis bots, including to make it harder to investigate their site networks. The May 2022 source material lists AhrefsBot as the user-agent for Ahrefs; disallowing the root path is intended to restrict its access to the entire site.
The source lists separate names for different Semrush functions: SiteAuditBot, SemrushBot-BA, SemrushBot-SI, SemrushBot-SWA, SemrushBot-CT, SemrushBot-BM, SplitSignalBot and SemrushBot-COUB. These are associated, respectively, with technical audits, link audits, page checks, SWA, content analysis and publication tracking, brand monitoring, SplitSignal and Content Outline Builder. Before configuring restrictions, check the service documentation for the current bot names and purposes: the list provided dates from 2022.
Server-side blocking via .htaccess
On an Apache server, access can also be restricted through the .htaccess file, for example by IP address. The source material provides an example for Ahrefs and notes that all relevant address ranges must be included for a complete block. Specific addresses and ranges should be checked against the service documentation rather than assuming that a historical example remains current.
Configuration errors can disrupt the site or server. Before making changes in a live environment, make sure you understand the settings and test them separately.
Crawl restrictions and server-side blocking serve different purposes. Choosing precise rules helps avoid blocking useful search engine crawlers while reducing unwanted automated activity, but it does not by itself make a site invulnerable.
Source: https://www.searchenginejournal.com/prevent-bot-crawling/450430/
Discussion
Sign in or create an account, to join the discussion.