Last active
April 14, 2025 12:13
-
-
Save gwire/4599a301a4c2beca9afa9a1e9f070cda to your computer and use it in GitHub Desktop.
AWS WAF Rule for blocking WordPress search requests by Bingbot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Name": "BingbotSearch", | |
"Priority": 13, | |
"Statement": { | |
"AndStatement": { | |
"Statements": [ | |
{ | |
"ByteMatchStatement": { | |
"SearchString": "bingbot", | |
"FieldToMatch": { | |
"SingleHeader": { | |
"Name": "user-agent" | |
} | |
}, | |
"TextTransformations": [ | |
{ | |
"Priority": 0, | |
"Type": "NONE" | |
} | |
], | |
"PositionalConstraint": "CONTAINS" | |
} | |
}, | |
{ | |
"SizeConstraintStatement": { | |
"FieldToMatch": { | |
"SingleQueryArgument": { | |
"Name": "s" | |
} | |
}, | |
"ComparisonOperator": "GT", | |
"Size": 0, | |
"TextTransformations": [ | |
{ | |
"Priority": 0, | |
"Type": "NONE" | |
} | |
] | |
} | |
} | |
] | |
} | |
}, | |
"Action": { | |
"Block": { | |
"CustomResponse": { | |
"ResponseCode": 429 | |
} | |
} | |
}, | |
"VisibilityConfig": { | |
"SampledRequestsEnabled": true, | |
"CloudWatchMetricsEnabled": true, | |
"MetricName": "BingbotSearch" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For some reason Bingbot is sending (replaying?) search requests that have no relevance to the site. (Weird stuff like
/?s=erotic+sims+4+mods
)I don't know how to block these without blocking non-search pages, which should still be indexed. Just adding
nofollow
etc to the meta data for searches doesn't prevent the searches from happening.This AWS WAF rule blocks any User-Agent containing "bingbot" from making WordPress style searches
?s=
- obviously it needsUser-Agent
to be preserved at the point of assessment.