Referer spam is a kind of spamdexing (spamming aimed at search engines). The technique involves making web site requests using a fake referer url that points to certain site. Sites that publicize their access logs, including referer statistics, will then end up linking to the spammer’s site. The spammer will then get backlink. Bloggers often display links to the most frequent or most recent web site visiting their blog. Spammers are spamming the log files in order to have their web sites listed on those referer links. It will also get traffic if someone click on the referer. They are probably being taken to a sales page, like this one: top-internet-sites dot com/new/.
There are a couple of ways to do this. The most elegant way of doing this is by creating an application which when run will visit your blog , and leave a custom referer in your logs. You can do this by changing the HTTP referer, whic identifies from the point of view of an internet webpage of the resource which links to it. Another way is to include an image tag in their page’s that calls your web site’s home page. No image is loaded, but visitors will generate a hit on your site which is logged by the server.
So how do you block these spammers? One way is by using htaccess. When spammers visit your website, they are redirected to another page. Put this code in your htaccess file:
RewriteEngine On
Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} ^http://(www\.)?spammer1.com.*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?spammer2.com.*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?spammer3.com.*$
RewriteRule \.*$ http://www.other-website.com [L,R]
Change the spammer.com with the name of sites found spamming your logs. The “L” flag in RewriteRule means to stop the rewriting process here and don’t apply any more rewrite rules. While the “R” flag is used to force a external redirection. If no code is given, a HTTP response of 302 (MOVED TEMPORARILY) will be returned. If you want to use other response codes in the range 300-400, simply specify the appropriate number. You can learn more about htaccess by viewing this file http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html