Smartlab Software logo

Stop Referrer Spam

AWStats logoHow to stop referrer spam.

  1. Acquire AWStats, other programs, and pertinent information
  2. Install AWStats on the 1and1 shared server
  3. Install AWStats on your computer
  4. Set up the AWStats config file
  5. Create a usable log file
  6. Create/update the AWStats database
  7. Create a traffic web page
  8. Create report batch files
  9. Analyze the traffic page
  10. Tasks

Extending AWStats

  1. Extras
  2. Geographic Plug-ins
  3. How To

Help

  1. Glossary
  2. FAQ
  3. Pages not found FAQ
  4. Stop Referrer Spam

Stop Referrer Spam using Apache's htaccess File

This fix pertains to apache servers only. It requires modification to the .htaccess file which is in the root directory on the server. Always create a backup of the .htaccess file just in case.

Since htaccess starts with a dot it is hidden from view in Expression Web and FrontPage.

Put this in the .htaccess file, changing "spammersite" to the name of sites found spamming your logs. The first site listed should not have "NC", and the last one should not have "OR".

If your site starts generating errors after you upload this file, remove the # from the first line. If you use Microsoft FrontPage on your site, do not do this. Changing the .htaccess file could interfere with FrontPage.

# Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://(www\.)?spamsite1.com.*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?spamsite2.com.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?spamsite3.com.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?spamsite4.com.*$ [NC] RewriteRule .* - [F,L]

This will give the spam site a forbidden error. If you prefer, you can rewrite that last line as "RewriteRule \.*$ http://www.some-other-website.com [R,L]" to redirect them to whatever site you choose (be nice!). Either way, it keeps them out of your referrer logs and there is no way to defeat it.

OR = or next. In this case, this means choose one of the RewriteCond rules rather than all of them. If the OR was left out, ALL the RewriteCond rules would have to be true.
NC = no case (upper or lower case acceptable)
F = forbidden
L = last of the affected rules
R = redirect URL