I have the following regex, which originates from a previous question of mine: IIS Rewrite Module exclude bots but allow GoogleBot
^$|b(?!.*googlebot.*b)w*(?:bot|crawl|spider)w*
The goal is to block all user agents with the parts bot, crawl or spider in it, but allow the Google Bot. This works to an extend. But the problem is that the second part of the regex is also triggered, even if “googlebot” is found in the string.
Below some examples what mean:
Googlebot/2.1 (+http://www.google.com)
Works fine, the ‘bot’ part in googlebot is ignored and the request is permitted.
Googlebot/2.1 (+http://www.google.com/bot.html)
Does not work, still triggers on the second ‘bot’ in the string and the request is blocked
KHTML, like Gecko; compatible; bingbot
Works fine, is triggered on the bot in bingbot and the request is blocked
So can someone help me to change the rexeg so the string with Googlebot/2.1 (+http://www.google.com/bot.html)
is allowed?