My home page has been plagued by referrer spam. I have done research on the net and came up with a few sites that provided useful ideas:
Referrer spam
Using .htaccess to block referrer spam
How to combat referrer spam
htaccess tutorial
Following some research and advice from the excellent support of my hosting provider I have done the following.
1. Protected the stats files generated by my hosting provider for each domain and sub domain. The referrer spam would be listed on those files. Now they cannot be viewed or accessed unless authorised. They are invisible to the web so to speak.
2. I know this is redundant but I also created a robots.txt file for each domain and sub domain so that access to the stats directory was denied to any robot.
2. Created htaccess files for each domain and sub domain. These list the urls of the sites that I wish to deny access. This is a tedious process. I have updated these htaccess files a few times. I suspect it will take some time to settle down.
3. I updated my sitemaps.xml file and resubmitted to Google so it no longer includes the references to the stats files.
The htaccess code advised by my provider looks like this:
setenvifnocase Referer “^http://(www\.)?unwantedreferrer.com” spam_ref=1
Order Allow,Deny
Allow from all
Deny from env=spam_ref
I protected the htaccess file by setting permissions for the to 644 or RW-R–R–.
The sources of the spam are the usual suspects (porn, medicines, finance, etc). They are using sites to promote themselves. It will add unwanted traffic to your site and in fact your site could be filtered or blocked by educational institutions if the words used in the urls are suspect.