
Google’s John Mueller Highlights Critical Robots.txt Mistake Leading to Search Spam Indexing
Google’s John Mueller recently clarified a common yet easily overlooked mistake in robots.txt file configurations that can severely disrupt website indexing and SEO goals. The advice came in response to a Reddit query concerning a Shopify website targeted by search box spam, where Google continued to index spammy pages despite a disallow directive in the robots.txt file.
The Problem: Search Box Spam
The issue began when a Reddit user reported that their client's Shopify store was hit by a search bar spam attack. In these attacks, spammers input search queries containing spammy keywords, links, or brand names into a website's internal search bar. This action generates a unique search results URL reflecting the query, which spammers then propagate online.
If search engines discover and index these URLs, the victim's website can end up ranking for unrelated, spammy terms.
To combat this, the client had added a rule to their robots.txt file to disallow the /search path. Additionally, they redirected the spammy URLs to another collection page on the store. The Reddit user asked whether they should serve a 404 page instead of a redirect to resolve the indexing issue.
The Robots.txt Trap: Specificity Wins
Upon reviewing the client’s robots.txt file, John Mueller identified why Google was ignoring the directive to block the search pages.
The file contained a dedicated section for user-agent: Googlebot within a custom rules block, alongside a separate, more extensive list of rules under the general user-agent: * section further down.
According to robots.txt standards, the most specific user-agent rule takes precedence. If a robots.txt file includes a specific block for user-agent: Googlebot, Googlebot will read only that section and completely ignore the directives under user-agent: *. Because the client's disallow rule for /search was placed only in the general user-agent: * section, Googlebot ignored it.
Mueller explained that to apply general rules to Googlebot, website owners must copy those rules directly into the Googlebot-specific section. Alternatively, they can list multiple user-agents together if they share the same rules, like so:
user-agent: googlebot
user-agent: otherbot
user-agent: imgsrc
user-agent: somethingpt
disallow: /fishes
disallow: /orange-cats
This behavior is not a system flaw but a deliberate feature, allowing webmasters to set unique instructions for specific crawlers while defining separate rules for the rest of the web.
A Better Solution: Noindex Over Robots.txt
While resolving the robots.txt syntax error prevents crawling, it may not completely stop Google from indexing the spammy URLs. This is because robots.txt only controls crawling (whether Googlebot can visit a page), not indexing (whether Google can list a page in search results). If Google finds external links pointing to a blocked URL, it can still index that URL.
Platforms like WordPress and Shopify offer built-in ways to mitigate search box spam. Specifically, Shopify provides a tutorial on automatically adding a noindex directive to all search results pages.
For a noindex tag to work, however, the pages must not be blocked by the robots.txt file. Googlebot needs to be allowed to crawl the search pages so it can discover and obey the noindex directive, which permanently prevents those pages from showing up in search results.
