Author Topic: Need help with code for .htaccess to block spam referrers  (Read 2878 times)

0 Members and 1 Guest are viewing this topic.

Offline Tombraider

  • Newbie
  • *
  • Posts: 40
    • View Profile
Need help with code for .htaccess to block spam referrers
« on: October 03, 2006, 04:18:43 PM »
Hi,
I am battling spam referrers and have tried various code remedies I have found around the internet but none of them actually work to give the spammer a 403 page when they go to details.php for specific pictures which is what they do.  Only banning their ip address specifically works and they keep changing them and have an endless supply of new ones.
Tried Vano's Ban and I'm not sure yet if it works yet....I'm a newbie and having trouble figuring out how to interpret the logs (wonderful mod though...thanks, vano!).  It may be showing them the banned message page and so that doesn't show up as zero bytes or 403 message. But I have to individually ban each ip and it's time consuming.  Would like to ban by keywords.

I have tried the following which don't seem to work. Two are to ban hyphenated sites in the referral and wish I could get the code right so that one of those would work.  One was given to me by tech support at my web hosting surface and not only doesn't keep the spammers out,  it kept ME out.  Can anyone give me proper code to ban these slimeballs?
[qcode]RewriteEngine On
 RewriteCond %{HTTP_REFERER} ^(http://www.)[a-z]+-[a-z]+- [NC]
 RewriteRule ^(.*) http://%{REMOTE_ADDR}/ [R=301,L][/qcode]
[qcode]RewriteEngine On
RewriteCond %{HTTP_REFERER} ^(http://)?(www\.)?[a-z]+\-[a-z]+\-.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^(http://)?(www\.)?[a-z]+\-[a-z]\.[a-z].*$ [NC,OR]
RewriteRule .* - [F,L][/qcode]
[qcode]# set the spam_ref variable
 SetEnvIfNoCase Referer "^http://(www.)?some-spammer.com" spam_ref=1
 
 SetEnvIfNoCase Referer "^http://(www.)?other-spammer.com" spam_ref=1
 
 SetEnvIfNoCase Referer "^casino-poker" spam_ref=1
 
 # block all referres that have spam_ref set
 <FilesMatch "(.*)">
 Order Allow,Deny
 Allow from all
 Deny from env=spam_ref
 </FilesMatch>[/qcode]
[qcode]
<Files 403.shtml>
order allow,deny
deny from env=BadReferrer
allow from all
</Files>
SetEnvIfNoCase Referer ".*(casino|gambling|poker|insurance).*" BadReferrer[/qcode]

Thanks in advance.
« Last Edit: October 03, 2006, 08:56:44 PM by Tombraider »