marius dot org » apache http://www.marius.org My random ramblings and musings Wed, 16 May 2012 06:03:29 +0000 en hourly 1 http://wordpress.org/?v=3.3.2 Blocking spam referrers http://www.marius.org/2007/08/31/blocking_spam_referrers/ http://www.marius.org/2007/08/31/blocking_spam_referrers/#comments Sat, 01 Sep 2007 00:21:43 +0000 marius http://www.marius.org/2007/08/31/blocking_spam_referrers.php Continue reading ]]> I’ve noticed through my website statistics program (I use Mint, thankyouverymuch), and I’ve noticed a couple of referrers that are suddenly referring a ton of hit to my website. I as curious what I did to attract these guys, so I peeked in my Apache logs a bit, and headed over to their website to find out what they’re all about.  Turns out, they’re basically opening a little frame in their site, and redirecting browsers to hit Movable Type trackback posts.  Mind you, I haven’t run Movable Type in … 6 months?

Now, my Movable Type install doesn’t exist anymore, but I do have a rewrite rule in my Apache configuration to capture 404 (resource not found) errors and have WordPress deal with them.  This is so you get pretty website addresses for me, rather than something ugly with variable names in the website address.

I decided that I wanted to block these guys.  Not because they’re bothering me in any way — the trackback script they’re trying to hit on my server doesn’t exist anymore — but they are skewing my website statistics.

Warning: technology speak ahead.

I knew that I could solve this with mod_rewrite in Apache, but I never remember the conditionals and syntax of anything more than a very basic rule rewrite.  A bit of searching online led me to ilovejackdaniels.com, who have already fixed this problem (and in a bigger way than I need to).  Basically, they use Apache’s mod_rewrite to forbid any request with a certain referrer field using RewriteCond and HTTP_REFERER variables.  I dropped the following two lines into my .htaccess, where I do the rest of my mod_rewrite work:

RewriteCond %{HTTP_REFERER} (tbsp2.php) [NC]
RewriteRule .* - [F]

What does this do?  The first line checks the HTTP_REFERER variable, and if it contains tbsp2.php, it executes the next RewriteRule directive.  In my case, two different websites (who I will not link to), have a page called /klx/tbsp2.php with the aforementioned frame sketchiness going on.  The RewriteRule directive tells Apache to not redirect the client or do any rule rewriting.  The magic is in the [F] – this tells Apache to return a 403 Forbidden error.  These don’t get tracked into my Mint statistics, so they’ll no longer skew my stats.  And now, anytime I notice additional spamming referrers, I’ll just add another RewriteCond to my configuration.

And no, I haven’t been misspelling "referrer" through this.  For some reason, RFC2616 documents this as "referer", which is wrong.

]]>
http://www.marius.org/2007/08/31/blocking_spam_referrers/feed/ 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 Buy Viagra Super Active From Canada Cheap Lumigan Eye Drops In Canada Free Viagra Sample Pills Deltasone On Line Purchase Deltasone Best Price Lisinopril On Line Pharmacy Lisinopril Lowest Price Serevent In Holland Netherlands Discount Prices Buy Levitra Professional In Us No Prescription Levitra Professional Buy Generic Sinemet With No Prescription Cheap Order Diflucan Now No Prescription Diflucan Cheap Tinidazole Canada Pharmacy Discount Prices Buying Noxide Safely Online Discount Prices Can I Buy Flovent Over The Counter In Australia Floxin Online Discount Free Viagra Samples Buy Fast Asleep Strips Online From Canada Discount Prices No Prescription Needed Pain Killers And Ipecac Syrup Online Pharmacy In Australia Buy Sublingual Viagra Online Cheap Viagra Soft Flavoured In Australia Viagra Soft Flavoured Mail Order Cheap Erexin V From Canada Erexin V Mail Order Decadron For Sale In Bristol England Uk Cheap No Prescription Diet Pills And Risperdal Online Buy Premarin Au Premarin Shipped From Canada Buy Medrol Sydney Australia Discount Prices Canadian Pharmacy Toronto Canada Phenergan Online Online Pharmacy Fda Approved Albendazole Online Avapro Italian Avapro Shipped From Canada How To Get Male Enhancement Pills Uk No Prescription Male Enhancement Pills Buying Brand Cialis In Usa Free Viagra Sample Pills Buy Tricor In Australia Free Viagra Samples No Prescription Lotrisone Online Pharmacy Cheap Buy Generic Unisom Uk Unisom By Mail Order Online Pharmacy Best Buy Zestril Online Cheap