Jack Barber Design & Technology

01947 878108 info@jackbarber.co.uk

Blocking Spam Referral Traffic with .htaccess

Over the past few weeks it became apparent that my server was handling quite a lot more traffic than it used to - resulting in nasty spikes in CPU and memory usage.

With my hosts (Bytemark in York) convinced there was nothing physically wrong with the server I dug a little deeper to try and ascertain what was causing the problem.

Looking at some Google Analytics data for a number of my busiest websites, it became apparent that they were handling a lot of referral traffic from unfavourable sources. I can't really say what the purpose of these sites are - but all they seem to do is direct quite a large amount of traffic to random websites.

Not only does this result in stretched server resources, but it also totally messes up the Google Analytics data (making a site look much busier than it actually is).

Blocking the referrers seemed like a good idea, so I've used .htaccess to do so, making use of this very usueful .htaccess generator.

This is what I now have at the top of my .htaccess files for the sites which appeared to be getting most of this referral traffic:

# BLOCK SITE REFERRERS
RewriteEngine on
 RewriteCond %{HTTP_REFERER} trafficmonetize\.org [NC,OR]
 RewriteCond %{HTTP_REFERER} 4webmasters\.org [NC,OR]
 RewriteCond %{HTTP_REFERER} webmonetizer\.net [NC,OR]
 RewriteCond %{HTTP_REFERER} 100dollars\-seo\.com [NC,OR]
 RewriteCond %{HTTP_REFERER} buttons\-for\-your\-website\.com [NC,OR]
 RewriteCond %{HTTP_REFERER} 24753470\.videos\-for\-your\-business\.com [NC,OR]
 RewriteCond %{HTTP_REFERER} semaltmedia\.com [NC,OR]
 RewriteCond %{HTTP_REFERER} best\-seo\-offer\.com [NC,OR]
 RewriteCond %{HTTP_REFERER} howtostopreferralspam\.eu [NC,OR]
 RewriteCond %{HTTP_REFERER} erot\.co [NC,OR]
 RewriteCond %{HTTP_REFERER} guardlink\.org [NC,OR]
 RewriteCond %{HTTP_REFERER} www1\.free\-social\-buttons\.com [NC,OR]
 RewriteCond %{HTTP_REFERER} www\.event\-tracking\.com [NC,OR]
 RewriteCond %{HTTP_REFERER} www2\.free\-social\-buttons\.com [NC,OR]
 RewriteCond %{HTTP_REFERER} free\-social\-buttons\.com [NC,OR]
 RewriteCond %{HTTP_REFERER} www3\.free\-social\-buttons\.com [NC,OR]
 RewriteCond %{HTTP_REFERER} www4\.free\-social\-buttons\.com [NC,OR]
 RewriteCond %{HTTP_REFERER} buttons\-for\-your\-website\.com [NC,OR]
 RewriteCond %{HTTP_REFERER} www7\.free\-social\-buttons\.com [NC,OR]
 RewriteCond %{HTTP_REFERER} www\.Get\-Free\-Traffic\-Now\.com [NC,OR]
 RewriteCond %{HTTP_REFERER} www5\.free\-social\-buttons\.com [NC,OR]
 RewriteCond %{HTTP_REFERER} best\-seo\-offer\.com [NC,OR]
 RewriteCond %{HTTP_REFERER} free\-share\-buttons\.com [NC,OR]
 RewriteCond %{HTTP_REFERER} www6\.free\-social\-buttons\.com [NC,OR]
 RewriteCond %{HTTP_REFERER} www8\.free\-social\-buttons\.com [NC]
RewriteRule .* - [F]

Feel free to copy this into your .htaccess file - the list of sites is compiled from the referrer data in from Google Analytics for a number of the affected sites.

Have you got any suggestions to make to improve this - or a different approach? Get in touch and let me know!

Tags