<?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>CSSKarma &#187; HTTP</title> <atom:link href="http://www.csskarma.com/blog/tag/http/feed/" rel="self" type="application/rss+xml" /><link>http://www.csskarma.com/blog</link> <description>display your style</description> <lastBuildDate>Tue, 31 Jan 2012 15:18:44 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>Using .htaccess to Prevent Bandwidth Theft</title><link>http://www.csskarma.com/blog/preventing-bandwidth-theft/</link> <comments>http://www.csskarma.com/blog/preventing-bandwidth-theft/#comments</comments> <pubDate>Thu, 02 Apr 2009 15:29:26 +0000</pubDate> <dc:creator>Tim</dc:creator> <category><![CDATA[Security]]></category> <category><![CDATA[htaccess]]></category> <category><![CDATA[HTTP]]></category><guid
isPermaLink="false">http://www.csskarma.com/blog/?p=447</guid> <description><![CDATA[Every once in a while Google Analytics will turn up a peculiar behavior where you can tell someone is linking directly to an image hosted on your Web server. Sometimes it can be for good reasons like giving you credit for a project, or make sure files are synced up (cross-domain projects); but it&#8217;s usually [...]]]></description> <content:encoded><![CDATA[<p><img
src="http://www.csskarma.com/images/articles/bandwidth-theft.jpg" alt="article banner"/></p><p>Every once in a while Google Analytics will turn up a peculiar behavior where you can tell someone is linking directly to an image hosted on your Web server. Sometimes it can be for good reasons like giving you credit for a project, or make sure files are synced up (cross-domain projects); but it&#8217;s usually just out of ignorance or laziness (or myspace).</p><p>Either way, hotlinking images like that steals your bandwidth and can effect the performance of your server. So you want to stop it.</p><p>There are a few ways you can do this; some people output a special image to a bandwidth thief that says something like &#8220;Stop stealing my images&#8221;. I don&#8217;t like that mainly because you&#8217;re intentionally degrading your bandwidth to teach someone a lesson about hotlinking? Bleh.</p><p>I prefer using a 403 error, it works just as well in my opinion, and gets the point accross.</p><h5>.htaccess code</h5><pre><code>RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?csskarma\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ - [F]</</code></pre><p>Put that in your .htaccess file (in your root directory). If you don't have an .htaccess file, just create an empty file in the root and name it ".htaccess". Then put this code in there and you'll be good to go.</p><p>Don't forget to change out "csskarma" for your web site. You'll definitely notice if you forget that bit.</p><h4>What's going on</h4><p>Turn on the rewrite condition:</p><pre><code>RewriteEngine On</code></pre><p>Match any request for csskarma.com (NC means "no case" it will match upper or lower case requests):</p><pre><code>RewriteCond %{HTTP_REFERER} !^http://(.+\.)?csskarma\.com/ [NC]</code></pre><p>Allow empty requests, these are harmless and often 404 errors anyway</p><pre><code>RewriteCond %{HTTP_REFERER} !^$</code></pre><p>Replace the stolen image with a 403 "forbidden" error</p><pre><code>RewriteRule .*\.(jpe?g|gif|bmp|png)$ - [F]</code></pre>]]></content:encoded> <wfw:commentRss>http://www.csskarma.com/blog/preventing-bandwidth-theft/feed/</wfw:commentRss> <slash:comments>10</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 7/14 queries in 0.041 seconds using disk: basic

Served from: www.csskarma.com @ 2012-02-09 16:00:46 -->
