.htaccess and spam

May 25, 2006

You know, while I sit here, working on a new theme to put up on the site so people can download it, and waiting for my hair to dry, I just remembered one of the best things I have to offer people.

My .htaccess file.

I’ve developed my .htaccess file over the last few years, and haven’t had to touch it in about 2 years, because it’s so effective in controlling spam. I won’t confirm the types of spam it controls, because I’ve also had other methods in place – but one thing I do know is that it controls referer spam.

For those of you that don’t know, here is the Wiki on referer spam:

Referer spam is a kind of spamdexing (spamming aimed at search engines). The technique involves making repeated web site requests using a fake referer url pointing to a spam-advertised site. Sites that publicize their access logs, including referer statistics, will then also link to the spammer’s site.

This benefits the spammer because of the free link, and also gives the spammer’s site improved search engine link placement due to link-counting algorithms that search engines use.”

In other words, the lazy jerks ride your tails, and most likely, you don’t even know they’re doing it. If you want to see, go log into your host’s cPanel (or whatever you use) and check your web stats for referers. Betcha there’s a bunch of sites that “refer” to you, with names associated with pharmaceuticals, porn, celebrities and poker, among other things.

I got so sick and tired of seeing this stuff in my logs…I could never see who was actually linking to me and get correct stats. So, I began working on an .htaccess file to elimate the problem.

I won’t promise this – but I’ve also noticed my comment spam has been reduced by a lot on my blogs. However, my personal blog actually utlizes Moveable Type (not WordPress, like this one), and I’ve found the MT Blacklist to be something I can’t live without – and I’m quite sure that the MT Blacklist had a large helping hand in working with the .htaccess file in getting my spam reduced to almost nothing.

That all being said, I’m willing to share my .htaccess file with you. So, without further ado…

AddType text/html .shtml .shtm .htm .html
AddHandler server-parsed .shtml .shtm .htm .html
ErrorDocument 401 http://YOUR URL HERE/error/unauthorized.html
ErrorDocument 403 http://YOUR URL HERE/error/forbidden.html
ErrorDocument 404 http://YOUR URL HERE/error/unknown.html
ErrorDocument 505 http://YOUR URL HERE/error/server.html
Options -Indexes
Options +FollowSymlinks
RewriteEngine on

RewriteCond %{HTTP_REFERER} ^http://(www\.)?iconsurf\.com/ [NC]
RewriteRule \.(ico)$ - [F]
RewriteCond %{HTTP_REFERER} !.*YOUR URL\.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !.*YOUR SECONDARY URL\.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://([^/]+)google\..*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://([^/]+)altavista\..*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://([^/]+)yahoo\..*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://([^/]+)msn\..*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://([^/]+)a9\..*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://([^/]+)lycos\..*$ [NC]
RewriteCond %{REQUEST_URI} !/403.shtml$ [NC]
RewriteCond %{HTTP_REFERER} advair [OR]
RewriteCond %{HTTP_REFERER} allegra [OR]
RewriteCond %{HTTP_REFERER} ambien [OR]
RewriteCond %{HTTP_REFERER} amoxicillin [OR]
RewriteCond %{HTTP_REFERER} baccarat [OR]
RewriteCond %{HTTP_REFERER} bet [OR]
RewriteCond %{HTTP_REFERER} blackjack [OR]
RewriteCond %{HTTP_REFERER} cash [OR]
RewriteCond %{HTTP_REFERER} casino [OR]
RewriteCond %{HTTP_REFERER} celeb [OR]
RewriteCond %{HTTP_REFERER} cheap [OR]
RewriteCond %{HTTP_REFERER} cialis [OR]
RewriteCond %{HTTP_REFERER} craps [OR]
RewriteCond %{HTTP_REFERER} credit [OR]
RewriteCond %{HTTP_REFERER} deal [OR]
RewriteCond %{HTTP_REFERER} debt [OR]
RewriteCond %{HTTP_REFERER} drug [OR]
RewriteCond %{HTTP_REFERER} effexor [OR]
RewriteCond %{HTTP_REFERER} equity [OR]
RewriteCond %{HTTP_REFERER} faxo [OR]
RewriteCond %{HTTP_REFERER} finance [OR]
RewriteCond %{HTTP_REFERER} gambling [OR]
RewriteCond %{HTTP_REFERER} hold-em [OR]
RewriteCond %{HTTP_REFERER} holdem [OR]
RewriteCond %{HTTP_REFERER} iconsurf [OR]
RewriteCond %{HTTP_REFERER} insurance [OR]
RewriteCond %{HTTP_REFERER} interest [OR]
RewriteCond %{HTTP_REFERER} internetsupervision [OR]
RewriteCond %{HTTP_REFERER} keno [OR]
RewriteCond %{HTTP_REFERER} levitra [OR]
RewriteCond %{HTTP_REFERER} lipitor [OR]
RewriteCond %{HTTP_REFERER} loan [OR]
RewriteCond %{HTTP_REFERER} meds [OR]
RewriteCond %{HTTP_REFERER} money [OR]
RewriteCond %{HTTP_REFERER} mortgage [OR]
RewriteCond %{HTTP_REFERER} omaha [OR]
RewriteCond %{HTTP_REFERER} paxil [OR]
RewriteCond %{HTTP_REFERER} pharmacy [OR]
RewriteCond %{HTTP_REFERER} pharmacies [OR]
RewriteCond %{HTTP_REFERER} phentermine [OR]
RewriteCond %{HTTP_REFERER} pheromone [OR]
RewriteCond %{HTTP_REFERER} pills [OR]
RewriteCond %{HTTP_REFERER} poker [OR]
RewriteCond %{HTTP_REFERER} refinance [OR]
RewriteCond %{HTTP_REFERER} roulette [OR]
RewriteCond %{HTTP_REFERER} scout [OR]
RewriteCond %{HTTP_REFERER} seventwentyfour [OR]
RewriteCond %{HTTP_REFERER} slot [OR]
RewriteCond %{HTTP_REFERER} syntryx [OR]
RewriteCond %{HTTP_REFERER} texas [OR]
RewriteCond %{HTTP_REFERER} tournament [OR]
RewriteCond %{HTTP_REFERER} tramadol [OR]
RewriteCond %{HTTP_REFERER} tramidol [OR]
RewriteCond %{HTTP_REFERER} valtrex [OR]
RewriteCond %{HTTP_REFERER} viagra [OR]
RewriteCond %{HTTP_REFERER} vicodin [OR]
RewriteCond %{HTTP_REFERER} win [OR]
RewriteCond %{HTTP_REFERER} xanax [OR]
RewriteCond %{HTTP_REFERER} zanax [OR]
RewriteCond %{HTTP_REFERER} zoloft [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?.*(-|.)?adult(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?.*(-|.)?anal(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?.*(-|.)?blow.?job(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?.*(-|.)?gay(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?.*(-|.)?incest(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?.*(-|.)?mature(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?.*(-|.)?nude(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?.*(-|.)?porn(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?.*(-|.)?pus*y(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?.*(-|.)?sex(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?.*(-|.)?teen(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?.*(-|.)?tits(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?.*(-|.)?titten(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?38ha(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?4free(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?4hs8(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?4t(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?4u(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?6q(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?8gold(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?911(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?abalone(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?adminshop(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?adultactioncam(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?aizzo(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?alexa(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?alphacarolinas(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?amateur(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?amateurxpass(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?ansar-u-deen(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?atelebanon(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?beastiality(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?bestiality(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?belize(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?best-deals(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?blogincome(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?bontril(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?bruce-holdeman(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?vixen1(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?ca-america(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?chatt-net(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?commerce(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?condo(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?conjuratia(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?consolidate(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?coswap(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?crescentarian(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?crepesuzette(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?dating(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?devaddict(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?discount(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?domainsatcost(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?doobu(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?e-site(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?egygift(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?empathica(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?empirepoker(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?e-poker-2005(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?escal8(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?eurip(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?exitq(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?eyemagination(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?fastcrawl(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?fearcrow(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?ferretsoft(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?fick(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?finance(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?flafeber(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?fidelityfunding(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?freakycheats(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?freeality(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?fuck(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?future-2000(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?gabriola(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?gallerylisting(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?gb.com(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?globusy(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?golf-e-course(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?gospelcom(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?gradfinder(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?hasfun(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?herbal(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?hermosa(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?highprofitclub(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?hilton(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?teaminspection(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?hotel(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?houseofseven(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?hurricane(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?iaea(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?ime(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?info(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?ingyensms(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?inkjet-toner(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?isacommie(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?istarthere(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?it.tt(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?italiancharms(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?iwantu(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?jfcadvocacy(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?jmhic(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?juris(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?kylos(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?laser-eye(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?leathertree(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?lillystar(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?linkerdome(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?livenet(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?low-limit(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?lowest-price(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?macsurfer(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?mall.uk(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?maloylawn(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?marketing(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?mcdortaklar(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?mediavisor(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?medications(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?mirror.sytes(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?mp3(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?(-|.)musicbox1(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?naked(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?netdisaster(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?netfirms(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?newtruths(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?no-limit(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?nude(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?nudeceleb(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?nutzu(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?odge(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?oiline(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?onlinegamingassoc(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?outpersonals(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?pagetwo(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?paris(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?passions(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?peblog(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?peng(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?perfume-cologne(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?personal(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?php-soft(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?pics(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?pisoc(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?pisx(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?popwow(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?porn(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?prescriptions(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?printdirectforless(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?ps2cool(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?psnarones(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?psxtreme(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?quality-traffic(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?registrarprice(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?reliableresults(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?rimpim(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?ro7kalbe(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?rohkalby(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?ronnieazza(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?rulo.biz(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?s5(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?samiuls(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?searchedu(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?seventwentyfour(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?seventwentyfour.*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?sex(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?sexsearch(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?sexsq(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?shoesdiscount(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?site-4u(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?site5(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?slatersdvds(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?sml338(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?sms(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?smsportali(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?software(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?sortthemesitesby(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?spears(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?spoodles(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?sportsparent(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?stmaryonline(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?strip(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?suttonjames(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?talk.uk-yankee(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?tecrep-inc(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?teen(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?terashells(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?thatwhichis(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?thorcarlson(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?tmsathai(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?traffixer(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?tranny(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?valeof(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?video(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?vinhas(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?vixen1(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?vpshs(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?vrajitor(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?w3md(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?webdevsquare(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?whois(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?withdrawal(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?worldemail(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?wslp24(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?ws-op(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?xopy(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?xxx(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?yelucie(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?youradulthosting(-|.).*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?(-|.)zindagi(-|.).*$ [NC]
RewriteRule .* - [F]
deny from 217.46.255.241
deny from 65.112.44.225
deny from 64.246.161.26

Copy that sucker and paste it into your root folder of your server. Of course, you’ll have to make some changes, but this’ll get you going.

Basically, the very first section:

AddType text/html .shtml .shtm .htm .html
AddHandler server-parsed .shtml .shtm .htm .html

..is not necessary. That is there for my websites, so that I can use .shtml includes in my pages. If you have no need for this, then by all means remove it.

This section:

ErrorDocument 401 http://YOUR URL HERE/error/unauthorized.html
ErrorDocument 403 http://YOUR URL HERE/error/forbidden.html
ErrorDocument 404 http://YOUR URL HERE/error/unknown.html
ErrorDocument 505 http://YOUR URL HERE/error/server.html

…is for error handling. Rather than use my host/server’s default error pages, these few lines allow me to create custom error pages that follow the themes fo my websites. I get to be as creative as I like, and anytime I want to change it, I simply edit the HTML document and upload in my public_html space on the server.

Again, if you don’t want this, you don’t need it – delete away.

But the real meat of everything is the rest. Pay specific attention to this section:

RewriteCond %{HTTP_REFERER} !.*YOUR URL\.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !.*YOUR SECONDARY URL\.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://([^/]+)google\..*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://([^/]+)altavista\..*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://([^/]+)yahoo\..*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://([^/]+)msn\..*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://([^/]+)a9\..*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://([^/]+)lycos\..*$ [NC]

I have several domain names on my server that I use. I want to be sure that, when someone is actually refered from one of my own websites, that they are included in my stats. So I put in my own domain names to be sure things are free and clear from being considered spam. If you only have one domain, cool. Just put in one and delete the “Your Secondary URL” line. If you have more than two, by all means, copy and add to your heart’s desire.

The rest of the list is allowing search engines to come and index my pages. I don’t want to bar them access, either!

After implementing this .htaccess file, I’ve had my referer spam drop to almost nil. Every now and again, a new thing slips through (some new drug on the market or whatever), and I’ll start getting them again. All I have to do is pay attention to particular words within the domain, and copy one of the “meaty” lines and insert the word as needed.

Wonderful thing, it is. (call me Yoda, if you must.) Hopefully it helps you out, too!

View Comments

Sorry, comments are now closed on this post. You may thank the spammers for that one. But if you have any questions, please feel free to email me and ask - maybe it'll make for a good update in a future post. :)