1

This is really messing with my Analytics. I've previously blocked Semalt with the following code in my .htaccess

SetEnvIfNoCase Via evil-spam-proxy spammer=yes
SetEnvIfNoCase Referer evil-spam-domain.com spammer=yes
SetEnvIfNoCase Referer evil-spam-keyword spammer=yes
SetEnvIfNoCase Via pinappleproxy spammer=yes
SetEnvIfNoCase Referer semalt.com spammer=yes
SetEnvIfNoCase Referer poker spammer=yes

Order allow,deny
Allow from all
Deny from env=spammer

However I don't really know how the code works, it appears to be blocking other bots too (I think) but the code seems a little different for some of them. How can I adapt this to account for rank-checker.online also?

Update

I've updated my .htaccess file with the following code:

# block spam bots

RewriteCond %{HTTP_REFERER} ^http://.*semalt\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://.*rank-checker\.online/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://.*site-auditor\.online/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://.*monetizationking\.net/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://.*fix-website-errors\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://.*free-video-tool\.com/ [NC]
RewriteRule ^(.*)$ – [F,L]

However I am still getting some bots visiting my analytics. For example today I had a few referrals from monetizationking.net despite it being in my blocked list above.

2
  • I can't see how that bit of code would reliably block "Semalt" (or any other "evil" bot)? I would have thought you should be checking against User-Agent (although whether that works reliably will be dependent on the bot).
    – MrWhite
    Jun 15, 2016 at 10:12
  • 1
    Many Analytics spammers insert the data without even visiting your site. They just ping Google's trackers directly saying that they visited your site (without actually doing so). It is likely that your .htacces rules will have no effect on the spam whatsoever. Jun 15, 2016 at 10:33

2 Answers 2

3

This isn't a direct answer to your question but to your problem:

Try a hostname filter on your Analytics account instead. Filter only for your domain. The only situation in which you'll get views without your domain being the hostname is if you're serving content on other domains - such as via an iFrame.

When it comes to crawlers, there's many techniques. I block 'mozilla compatible user agent' as a user agent as a lazy option. You can also match lists, for example: http://help.analyticsedge.com/spam-filter/definitive-guide-to-removing-google-analytics-spam/

2

I've started using the following code:

RewriteCond %{HTTP_REFERER} ^http://.*[bad_referrer]\.com/ [NC]
RewriteRule ^(.*)$ – [F,L]

This looks for the referrer, in your case semalt.com, and creates a bad request. If you want to add more conditions use [NC,OR] until you get to the last item.

If mod_rewrite isn't available, this technique will not work.

You can also find more information on the Apache Docs.

Edit: For blocking semalt, you would do the following, replacing the [bad_referrer] text with the domain you want to block.

RewriteCond %{HTTP_REFERER} ^http://.*semalt\.com/ [NC]
5
  • thanks! how do I word the bad_referrer bit? do I keep the asterisk in there and have the URL after it?
    – user47053
    Jul 4, 2016 at 13:35
  • @pealo86 I've updated the answer. Jul 5, 2016 at 12:18
  • thanks, I still seem to be having visits from some however. I will update my question with my updated code now
    – user47053
    Jul 13, 2016 at 13:46
  • @pealo86 add "OR" to everything but the last entry. Should read [NC,OR] Jul 30, 2016 at 23:58
  • thanks but that still doesn't seem to work unfortunately :( I've updated the code in my question, does everything look in order? Also I've only just noticed some comments on my question saying that my method will most likely have no effect on spam bots?
    – user47053
    Aug 28, 2016 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.