My .htaccess to stop referral spam

Discussion in 'Apache' started by mdvaldosta, Apr 19, 2006.

  1. #1
    I ganked this from someplace on the net, can't remember where or I'd give credit. It successfully stops most of the referral spam, and when someone sneaks by I can add them to the list if need be. Obvously you can edit it to be smaller if you like and still catch most of them. Here you go:

    
    # Block Referrer Spam
    
    # Drugs / Herbal
    
    RewriteCond %{HTTP_REFERER} (sleep-?deprivation) [NC,OR]
    RewriteCond %{HTTP_REFERER} (sleep-?disorders) [NC,OR]
    RewriteCond %{HTTP_REFERER} (insomnia) [NC,OR]
    RewriteCond %{HTTP_REFERER} (phentermine) [NC,OR]
    RewriteCond %{HTTP_REFERER} (phentemine) [NC,OR]
    RewriteCond %{HTTP_REFERER} (vicodin) [NC,OR]
    RewriteCond %{HTTP_REFERER} (hydrocodone) [NC,OR]
    RewriteCond %{HTTP_REFERER} (levitra) [NC,OR]
    RewriteCond %{HTTP_REFERER} (hgh-) [NC,OR]
    RewriteCond %{HTTP_REFERER} (-hgh) [NC,OR]
    RewriteCond %{HTTP_REFERER} (ultram-) [NC,OR]
    RewriteCond %{HTTP_REFERER} (-ultram) [NC,OR]
    RewriteCond %{HTTP_REFERER} (cialis) [NC,OR]
    RewriteCond %{HTTP_REFERER} (soma-) [NC,OR]
    RewriteCond %{HTTP_REFERER} (-soma) [NC,OR]
    RewriteCond %{HTTP_REFERER} (diazepam) [NC,OR] 
    RewriteCond %{HTTP_REFERER} (gabapentin) [NC,OR]
    RewriteCond %{HTTP_REFERER} (celebrex) [NC,OR]
    RewriteCond %{HTTP_REFERER} (viagra) [NC,OR]
    RewriteCond %{HTTP_REFERER} (fioricet) [NC,OR]
    RewriteCond %{HTTP_REFERER} (ambien) [NC,OR]
    RewriteCond %{HTTP_REFERER} (valium) [NC,OR]
    RewriteCond %{HTTP_REFERER} (zoloft) [NC,OR]
    RewriteCond %{HTTP_REFERER} (finasteride) [NC,OR]
    RewriteCond %{HTTP_REFERER} (lamisil) [NC,OR]
    RewriteCond %{HTTP_REFERER} (meridia) [NC,OR]
    RewriteCond %{HTTP_REFERER} (allegra) [NC,OR]
    RewriteCond %{HTTP_REFERER} (diflucan) [NC,OR]
    RewriteCond %{HTTP_REFERER} (zovirax) [NC,OR]
    RewriteCond %{HTTP_REFERER} (valtrex) [NC,OR]
    RewriteCond %{HTTP_REFERER} (lipitor) [NC,OR]
    RewriteCond %{HTTP_REFERER} (proscar) [NC,OR]
    RewriteCond %{HTTP_REFERER} (acyclovir) [NC,OR]
    RewriteCond %{HTTP_REFERER} (sildenafil) [NC,OR]
    RewriteCond %{HTTP_REFERER} (tadalafil) [NC,OR]
    RewriteCond %{HTTP_REFERER} (xenical) [NC,OR]
    RewriteCond %{HTTP_REFERER} (melatonin) [NC,OR]
    RewriteCond %{HTTP_REFERER} (xanax) [NC,OR]
    RewriteCond %{HTTP_REFERER} (herbal) [NC,OR]
    RewriteCond %{HTTP_REFERER} (drugs) [NC,OR]
    RewriteCond %{HTTP_REFERER} (lortab) [NC,OR]
    RewriteCond %{HTTP_REFERER} (adipex) [NC,OR]
    RewriteCond %{HTTP_REFERER} (propecia) [NC,OR]
    RewriteCond %{HTTP_REFERER} (carisoprodol) [NC,OR]
    RewriteCond %{HTTP_REFERER} (tramadol) [NC]
    RewriteRule .* - [F]
    
    # Porn
    
    RewriteCond %{HTTP_REFERER} (porno) [NC,OR]
    RewriteCond %{HTTP_REFERER} (shemale) [NC,OR]
    RewriteCond %{HTTP_REFERER} (gangbang) [NC,OR]
    RewriteCond %{HTTP_REFERER} (-cock) [NC,OR]
    RewriteCond %{HTTP_REFERER} (-anal) [NC,OR]
    RewriteCond %{HTTP_REFERER} (-orgy) [NC,OR]
    RewriteCond %{HTTP_REFERER} (cock-) [NC,OR]
    RewriteCond %{HTTP_REFERER} (anal-) [NC,OR]
    RewriteCond %{HTTP_REFERER} (orgy-) [NC,OR]
    RewriteCond %{HTTP_REFERER} (singles-?christian) [NC,OR]
    RewriteCond %{HTTP_REFERER} (dating-?christian) [NC,OR]
    RewriteCond %{HTTP_REFERER} (cumeating) [NC,OR]
    RewriteCond %{HTTP_REFERER} (cream-?pies) [NC,OR]
    RewriteCond %{HTTP_REFERER} (cumsucking) [NC,OR]
    RewriteCond %{HTTP_REFERER} (cumswapping) [NC,OR]
    RewriteCond %{HTTP_REFERER} (cumfilled) [NC,OR]
    RewriteCond %{HTTP_REFERER} (cumdripping) [NC,OR]
    RewriteCond %{HTTP_REFERER} (krankenversicherung) [NC,OR]
    RewriteCond %{HTTP_REFERER} (cumpussy) [NC,OR]
    RewriteCond %{HTTP_REFERER} (suckingcum) [NC,OR]
    RewriteCond %{HTTP_REFERER} (drippingcum) [NC,OR]
    RewriteCond %{HTTP_REFERER} (pussycum) [NC,OR]
    RewriteCond %{HTTP_REFERER} (swappingcum) [NC,OR]
    RewriteCond %{HTTP_REFERER} (eatingcum) [NC,OR]
    RewriteCond %{HTTP_REFERER} (cum-) [NC,OR]
    RewriteCond %{HTTP_REFERER} (-cum) [NC,OR]
    RewriteCond %{HTTP_REFERER} (sperm) [NC,OR]
    RewriteCond %{HTTP_REFERER} (christian-?dating) [NC,OR]
    RewriteCond %{HTTP_REFERER} (jewish-?singles) [NC,OR]
    RewriteCond %{HTTP_REFERER} (sex-?meetings) [NC,OR]
    RewriteCond %{HTTP_REFERER} (swinging) [NC,OR]
    RewriteCond %{HTTP_REFERER} (swingers) [NC,OR]
    RewriteCond %{HTTP_REFERER} (personals) [NC,OR]
    RewriteCond %{HTTP_REFERER} (sleeping) [NC,OR]
    RewriteCond %{HTTP_REFERER} (libido) [NC,OR]
    RewriteCond %{HTTP_REFERER} (grannies) [NC,OR]
    RewriteCond %{HTTP_REFERER} (mature) [NC,OR]
    RewriteCond %{HTTP_REFERER} (enhancement) [NC,OR]
    RewriteCond %{HTTP_REFERER} (sexual) [NC,OR]
    RewriteCond %{HTTP_REFERER} (gay-?teen) [NC,OR]
    RewriteCond %{HTTP_REFERER} (teen-?chat) [NC,OR]
    RewriteCond %{HTTP_REFERER} (gay-?chat) [NC,OR]
    RewriteCond %{HTTP_REFERER} (adult-?finder) [NC,OR]
    RewriteCond %{HTTP_REFERER} (adult-?friend) [NC,OR]
    RewriteCond %{HTTP_REFERER} (friend-?finder) [NC,OR]
    RewriteCond %{HTTP_REFERER} (friend-?adult) [NC,OR]
    RewriteCond %{HTTP_REFERER} (finder-?adult) [NC,OR]
    RewriteCond %{HTTP_REFERER} (finder-?friend) [NC,OR]
    RewriteCond %{HTTP_REFERER} (discrete-?encounters) [NC,OR]
    RewriteCond %{HTTP_REFERER} (cheating-?wives) [NC,OR]
    RewriteCond %{HTTP_REFERER} (housewives) [NC,OR]
    RewriteCond %{HTTP_REFERER} (\-sex\.) [NC,OR]
    RewriteCond %{HTTP_REFERER} (xxx) [NC,OR]
    RewriteCond %{HTTP_REFERER} (snowballing) [NC] 
    RewriteRule .* - [F]
    
    # Weight
    
    RewriteCond %{HTTP_REFERER} (fat-) [NC,OR] 
    RewriteCond %{HTTP_REFERER} (-fat) [NC,OR] 
    RewriteCond %{HTTP_REFERER} (diet) [NC,OR]
    RewriteCond %{HTTP_REFERER} (pills) [NC,OR]
    RewriteCond %{HTTP_REFERER} (weight) [NC,OR]
    RewriteCond %{HTTP_REFERER} (supplement) [NC] 
    RewriteRule .* - [F] 
    
    # Gambling
    
    RewriteCond %{HTTP_REFERER} (texas-?hold-?em) [NC,OR]
    RewriteCond %{HTTP_REFERER} (poker) [NC,OR]
    RewriteCond %{HTTP_REFERER} (casino) [NC,OR]
    RewriteCond %{HTTP_REFERER} (blackjack) [NC] 
    RewriteRule .* - [F]
    
    # Loans / Finance
    
    RewriteCond %{HTTP_REFERER} (mortgage) [NC,OR]
    RewriteCond %{HTTP_REFERER} (consolidation) [NC,OR]
    RewriteCond %{HTTP_REFERER} (refinancing) [NC,OR]
    RewriteCond %{HTTP_REFERER} (cash-?advance) [NC,OR]
    RewriteCond %{HTTP_REFERER} (cash-?money) [NC,OR]
    RewriteCond %{HTTP_REFERER} (pay-?day) [NC] 
    RewriteRule .* - [F]
    
    # User Agents
    
    RewriteCond %{HTTP_USER_AGENT} (Program\ Shareware|Fetch\ API\ Request) [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} (Microsoft\ URL\ Control) [NC]
    RewriteRule .* - [F]
    
    # Misc / Specific Sites
    
    RewriteCond %{HTTP_REFERER} (netwasgroup\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (nic4u\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (wear4u\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (foxmediasolutions\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (liveplanets\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (aeterna-tech\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (continentaltirebowl\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (chemsymphony\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (infolibria\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (globaleducationeurope\.net) [NC,OR]
    RewriteCond %{HTTP_REFERER} (soma\.125mb\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (mitglied\.lycos\.de) [NC,OR]
    RewriteCond %{HTTP_REFERER} (foxmediasolutions\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (jroundup\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (feathersandfurvanlines\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (conecrusher\.org) [NC,OR]
    RewriteCond %{HTTP_REFERER} (sbj-broadcasting\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (edthompson\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (codychesnutt\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (artsmallforsenate\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (axionfootwear\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (protzonbeer\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (candiria\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (bigsitecity\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (coresat\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (istarthere\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (amateurvoetbal\.net) [NC,OR]
    RewriteCond %{HTTP_REFERER} (alleghanyeda\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (xadulthosting\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (datashaping\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (zick\.biz) [NC,OR]
    RewriteCond %{HTTP_REFERER} (newprinceton\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (dvdsqueeze\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (xopy\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (webdevboard\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (devaddict\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (eaton-inc\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (whiteguysgroup\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (guestbookz\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (webdevsquare\.com) [NC,OR]
    RewriteCond %{HTTP_REFERER} (indfx\.net) [NC,OR]
    RewriteCond %{HTTP_REFERER} (snap\.to) [NC,OR]
    RewriteCond %{HTTP_REFERER} (2y\.net) [NC,OR]
    RewriteCond %{HTTP_REFERER} (astromagia\.info) [NC,OR]
    RewriteCond %{HTTP_REFERER} (free-?sms) [NC] 
    RewriteRule .* - [F]
    
    Code (markup):
     
    mdvaldosta, Apr 19, 2006 IP
    Smyrl, Will.Spencer and esiason14 like this.
  2. TheHoff

    TheHoff Peon

    Messages:
    1,530
    Likes Received:
    130
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Nice :) Does that many rewrites create additional load though?
     
    TheHoff, Apr 19, 2006 IP
  3. mdvaldosta

    mdvaldosta Peon

    Messages:
    4,079
    Likes Received:
    362
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Didn't notice a difference at all, and this was on a VPS with 4 forums and 20 sites getting 15k visits / day and I'm also using alot of mod-rewrite for the url's. But, if it's a concern, you can remove probably 3/4 of the RewriteCond leaving just the really common stuff.
     
    mdvaldosta, Apr 19, 2006 IP
    Mystique likes this.
  4. Mystique

    Mystique Well-Known Member

    Messages:
    2,579
    Likes Received:
    94
    Best Answers:
    2
    Trophy Points:
    195
    #4
    Thanks mdvaldosta

    Don't think this make difference on server load as my current .htaccess is 36k and the performance is the same as when it was just 1k
     
    Mystique, Apr 19, 2006 IP
  5. theblight

    theblight Peon

    Messages:
    246
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #5
    That would really keep me going, i really hate spams
     
    theblight, Apr 29, 2006 IP