<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>marius dot org &#187; apache</title>
	<atom:link href="http://www.marius.org/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.marius.org</link>
	<description>My random ramblings and musings</description>
	<lastBuildDate>Sun, 05 Feb 2012 10:01:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Blocking spam referrers</title>
		<link>http://www.marius.org/feeder/?FeederAction=clicked&#038;feed=Articles+%28RSS2%29&#038;seed=http%3A%2F%2Fwww.marius.org%2F2007%2F08%2F31%2Fblocking_spam_referrers%2F&#038;seed_title=Blocking+spam+referrers</link>
		<comments>http://www.marius.org/feeder/?FeederAction=clicked&#038;feed=Articles+%28RSS2%29&#038;seed=http%3A%2F%2Fwww.marius.org%2F2007%2F08%2F31%2Fblocking_spam_referrers%2F&#038;seed_title=Blocking+spam+referrers#comments</comments>
		<pubDate>Sat, 01 Sep 2007 00:21:43 +0000</pubDate>
		<dc:creator>marius</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[mint]]></category>
		<category><![CDATA[movable type]]></category>
		<category><![CDATA[spam]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.marius.org/2007/08/31/blocking_spam_referrers.php</guid>
		<description><![CDATA[I&#8217;ve noticed through my website statistics program (I use Mint, thankyouverymuch), and I&#8217;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 &#8230; <a href="http://www.marius.org/feeder/?FeederAction=clicked&#038;feed=Articles+%28RSS2%29&#038;seed=http%3A%2F%2Fwww.marius.org%2F2007%2F08%2F31%2Fblocking_spam_referrers%2F&#038;seed_title=Blocking+spam+referrers">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve noticed through my website statistics program (I use <a href="http://www.haveamint.com/">Mint</a>, thankyouverymuch), and I&#8217;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&#8217;re all about.&#xA0; Turns out, they&#8217;re basically opening a little frame in their site, and redirecting browsers to hit <a href="http://www.sixapart.com/movabletype/">Movable Type</a> <a href="http://en.wikipedia.org/wiki/TrackBack">trackback</a> posts.&#xA0; Mind you, I haven&#8217;t run Movable Type in &#8230; 6 months?</p>
<p>Now, my Movable Type install doesn&#8217;t exist anymore, but I do have a rewrite rule in my Apache configuration to capture 404 (resource not found) errors and have <a href="http://www.wordpress.org/">WordPress</a> deal with them.&#xA0; This is so you get pretty website addresses for me, rather than something ugly with variable names in the website address.</p>
<p>I decided that I wanted to block these guys.&#xA0; Not because they&#8217;re bothering me in any way &#8212; the trackback script they&#8217;re trying to hit on my server doesn&#8217;t exist anymore &#8212; but they are skewing my website statistics.</p>
<p>Warning: technology speak ahead.</p>
<p>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.&#xA0; A bit of searching online led me to <a href="http://www.ilovejackdaniels.com/apache/block-referrer-spam">ilovejackdaniels.com</a>, who have already fixed this problem (and in a bigger way than I need to).&#xA0; Basically, they use Apache&#8217;s <a href="http://httpd.apache.org/docs/2.0/misc/rewriteguide.html">mod_rewrite</a> to forbid any request with a certain referrer field using RewriteCond and HTTP_REFERER variables.&#xA0; I dropped the following two lines into my .htaccess, where I do the rest of my mod_rewrite work:</p>
<pre>RewriteCond %{HTTP_REFERER} (tbsp2.php) [NC]
RewriteRule .* - [F]</pre>
<p>What does this do?&#xA0; The first line checks the HTTP_REFERER variable, and if it contains tbsp2.php, it executes the next RewriteRule directive.&#xA0; 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.&#xA0; The RewriteRule directive tells Apache to not redirect the client or do any rule rewriting.&#xA0; The magic is in the [F] &#8211; this tells Apache to return a 403 Forbidden error.&#xA0; These don&#8217;t get tracked into my <a href="http://www.haveamint.com/">Mint</a> statistics, so they&#8217;ll no longer skew my stats.&#xA0; And now, anytime I notice additional spamming referrers, I&#8217;ll just add another RewriteCond to my configuration.</p>
<p>And no, I haven&#8217;t been misspelling &quot;referrer&quot; through this.&#xA0; For some reason, <a href="http://tools.ietf.org/html/rfc2616">RFC2616</a> documents this as &quot;referer&quot;, which is wrong.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.marius.org/feeder/?FeederAction=clicked&#038;feed=Articles+%28RSS2%29&#038;seed=http%3A%2F%2Fwww.marius.org%2F2007%2F08%2F31%2Fblocking_spam_referrers%2F&#038;seed_title=Blocking+spam+referrers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

