How to block refrer urls - what is the best method?

222 Views Asked by At

I am getting a lot of spam refer urls in my analytics causing an increase in my site's bounce rate. Some of the urls are using sub domains such as site1.spamsite.com and site2.spamsite.com. What is the best way to block these? I have looked at .htaccess and robots.txt... Thought I would ask the best practice / solution before I implement. Thanks.

2

There are 2 best solutions below

0
jmiller On BEST ANSWER

Tried various htaccess functions but kept getting sub domains getting through. Installed this plugin:

https://wordpress.org/plugins/block-referer-spam/

has all spam referrers listed already and is automatically updated everyday with the latest "black list"

4
hjpotter92 On

It does not matter whether they use subdomains or not. Try the following simplistic approach:

RewriteEngine On
RewriteCond %{HTTP_REFERER} ^https?://.*spamsite\.com/ [NC]
RewriteRule ^ – [F,L]