Forum Moderators: phranque

Message Too Old, No Replies

using a referral spam htaccess - not sure if its 'clean' code?

         

kmaisch

1:30 am on Jan 5, 2006 (gmt 0)

10+ Year Member


Here is my htaccess that I am using to block referral spam to my site. (i have removed the many keywords, etc - but this is the basic structure).

Does it look OK? Or is it messy?

Also - does anyone know if there is an easier way to block referrer spam? Is there a web service that maintains a frequently updated list that can be linked to from an htaccess file?

Cheers,
Kim

-----

php_flag allow_url_fopen on
RewriteEngine On

#These lines block agents commonly used to harvest URLs and email addresses.
RewriteCond %{HTTP_USER_AGENT} ^.*Indy\ Library.*$ [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*larbin2\.6\.3\@unspecified.*$ [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Microsoft\ URL\ Control.*$ [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Mozilla/4\.0\ .*Win\ 9x\ 4\.90.*$ [NC,OR]

#This one used to be the user agent for anonymizer
RewriteCond %{HTTP_USER_AGENT} ^.*TuringOS.*$ [NC,OR]

#These lines block bots that use your bandwidth for their own commercial reasons.
RewriteCond %{HTTP_USER_AGENT} ^abot.*$ [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^aipbot.*$ [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Linkwalker$ [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*nameprotect.*$ [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*TurnitinBot.*$ [NC,OR]

#These deny referrers with a domain name structure with hyphens
RewriteCond %{HTTP_REFERER} ^http://(www\.)?[a-z]+\-[a-z]+\-.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?[a-z]+\-[a-z]\.[a-z].*$ [NC,OR]

#These conditions are based on keywords anywhere in the URL.
RewriteCond %{HTTP_REFERER} ^http://(www\.)?.*(-¦.)azian(-¦.).*$ [NC,OR]
^http://(www\.)?.*(-¦.)#*$!(-¦.).*$ [NC]

RewriteRule ^(.*) http://%{REMOTE_ADDR}/ [R=301,L]

#For serious offenders or spammers - block access by IP address
<Files 403.shtml>
order allow,deny
allow from all
</Files>
deny from 12.22.85.3