-1

I have this spam bot showing in google analytics (screen capture). I tried blocking it using this htaccess configuration

RewriteCond %{HTTP:Accept-Language} (Trump) [NC]
RewriteRule .* www.google.com [L]

If the Accept-language contains the word "Trump" it got redirected to google.

I'm still getting new hits.

hunter99
  • 101

1 Answers1

1

Its better to detect the user-agent of this bot and block that user agent using the following code in .htaccess:

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} user_agent_name_here [NC]
RewriteRule .* - [F,L]

If there are a lot of different user-agent values each time then:

RewriteEngine On  
SetEnvIfNoCase Referer "^$" invalid_user_agent
SetEnvIfNoCase User-Agent "^user-agent1" invalid_user_agent
SetEnvIfNoCase User-Agent "^user-agent2" invalid_user_agent
SetEnvIfNoCase User-Agent "^user-agent2" invalid_user_agent
Deny from env=invalid_user_agent
Vikelidis Kostas
  • 967
  • 1
  • 6
  • 16