Tactus de Sonus

Post details: Referrer spam take 2.2

08/18/05

Referrer spam take 2.2

include dirname(Blocking the IP of a referer spammer is good but this is not a 100% solution as some of them change there ips as fast as you block them. Using some mod-rewrite rules is another way for blocking referrer spam. After g O o O o O o O o O o O o gling and technorati tagging on the subject a little I found a neat rule that send the culprit from where they came from instead of just serving them a simple forbidden page.
If you are on an Apache webserver you can add some rules to your "htaccess" file in order to implement this function.
I found also this rule :

RewriteCond %{HTTP_REFERER} ^(http://www.)[a-z]+-[a-z]+- [NC]

which block any domain where there is 2 - (dashes) in the domain name like "www.some-spammer-referer.com" as most spammer do use this type of domain name. I modified it to :

Don't forget to replace the word Keyword with whatever is needed like porn, vicodin, poker....

This is still not 100% efficient as you still need to add more keywords as new ones appear in your logfiles.

What I did also is a redirection from the public stats page whenever it is accessed with a referrer, as most of the spammer try to access mostly this page. So those who manage to pass the rules of the "htaccess" get redirected anyway. The only way to access this page is through a direct access (paste the URL in your browser location try it http://dondy.awebmedia.com/index.php?disp=stats and if you click here you get redirected back to this page). And instead of the referrer stats this page displays the banned IPs.
In order to do this redirection you need to make those changes below to the _main.php and to _stats.php pages from your b2evolution skin: