I have the following entry in my Awstats file:
Unknown robot (identified by 'bot*')
How can I block this bot?
I tried the following separately but none of them seems to be catching it:
RewriteCond %{HTTP_USER_AGENT} ^bot*
RewriteCond %{HTTP_USER_AGENT} bot\*
RewriteCond %{HTTP_USER_AGENT} bot[*]
Here is the full .htaccess code I am using:
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^bot*
RewriteRule .? - [F,L]
Tested three regex values (^bot*, bot\*, bot[*]) in the second line, none of them stopped the bot.
The asterisk (
*
) is not literal. AWStats is simply stating that it used that particular rule to check if the request was being made by a bot. In your case,bot*
means that the user agent string started withbot
, and it found a match.As the asterisk is not literal, you can use the following instead:
Note: I should say here that it is better to check your access logs to see exactly what these user agents are and block them specifically. You don't want to find yourself in a position whereby you are blocking bots that you might want.
Recommendation: Change your rule from
RewriteRule .? - [F,L]
toRewriteRule ^ - [F,L]