How to stop spam bot from accessing site using htaccess?

Viewed 1027

I have an apache server running WordPress, and recently I noticed large traffic from a spam bot more specifically bot-traffic.xyz which shows in the "Top Referrals" section when looking at Google Analytics. My question is since I don't know the source IP address, how do I block the spam bot using the .htaccess? I have found a post (https://moz.com/blog/how-to-stop-spam-bots-from-ruining-your-analytics-referral-data) pointing out the process, but I'm not sure since it's from 2015. The post says to do something like this:

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

If this is correct, how would I block bot-traffic.xyz? Can some describe what the above code is?

Thanks,

1 Answers

These bots are not hitting your site at all but rather using your Google Universal Analytics (UA) code and hitting Google directly & pushing their website URL in the page variable. Adding a rewrite rule won't help. Check your Apache log file and you won't find any traffic.

These URLs all go back to the same website run by someone selling fake traffic as a service. You can try to setup a filter in Google Analytics however that's going to be a game of wack-a-mole. Best way to get rid of this is to setup view filters in Google Analytics Universal. Admin icon (lower left) -> Filter (in right most column). Add a filter. Choose custom filter, exclude from Request URL. Then build regex to remove the offending sites.

Related