Protecting your content and bandwidth - page 2

Author: Steven Neiland
Published:

Warning: This blog entry was written two or more years ago. Therefore, it may contain broken links, out-dated or misleading content, or information that is just plain wrong. Please read on with caution.

Prevent Bandwidth Theft

Bandwidth theft is when another websites presents your material as there own and also uses your website to host the stolen resources. The framing method I discussed earlier is anexample of this.

While I dislike copyright violations I think of bandwidth theft as an even more serious crime. Not only are your intelectual property rights being violated, but you are also being made to pay for the theft of your resources by increased bandwidth usage charges.

Prevent Hotlinking With Mod_Rewrite

In addition to the framing example above, there is a second type of bandwidth theft known as hotlinking. Hotlinking is when a site other than your own links to an images (and other files) hosted on your site. This normally happens when someone has scraped your site and stolen your content. By hotlinking to your images/files they are presenting it as their own content, while at the same time using your site as a resource host so that you pay for the bandwidth being used and not them.

To combat this we can use a little mod_rewrite magic. Create a .htaccess file and place it in your assets directory (i.e. where you keep all your images etc) and paste in the following code. Also create an image file in the same directory which display a message such as "Potential Copyright Violation. This image is the property of x".

I have tried to explain each step in the code, but in essence what this code does is try to see if a request for a resource in this directory is coming from our site, or a select number of friendly sites (such as google) we want to give access to our resources. If none of the coditions are met a the file requested is of the listed type, we substitute it with our copyright violation image.

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
#Stop execution if this request comes from my site (including all different domain names for it)
RewriteCond %{HTTP_REFERER} !^http://neiland.net/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.neiland.net/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://neiland.dyndns.org/.*$ [NC]

#Stop execution if this request is from google (we do trust google dont we)
RewriteCond %{HTTP_REFERER} !google\. [NC]

#Stop execution if this request is from a search cache
RewriteCond %{HTTP_REFERER} !search\?q=cache [NC]

#If we got this far then this is likely a case of hotlinking
#So for any of the listed file types we substitute in our copyright violation image
RewriteRule .*\.(jpe?g|gif|bmp|png|txt|swf|flv)$ /myassetsdir/copyrightViolation.png [NC,L]

Further Reading

So there you have it, some simple ways of protecting your your intelectual property. There is alot more on this subject so I suggest some googling "copyright law for bloggers" if you want a more in depth analysis. One resource on the subject is http://www.copyright.gov/laws/

1 2

Reader Comments

web design worcester's Gravatar
web design worcester
Thursday, September 1, 2011 at 7:10:44 AM Coordinated Universal Time

nice article, very informative. but maybe you can discuss it further so that everyone could grasp the topic well. thanks for sharing.

web design portsmouth's Gravatar
web design portsmouth
Thursday, September 15, 2011 at 2:37:07 AM Coordinated Universal Time

thanks for sharing...interesting topic.

  • Please keep comments on-topic.
  • Please do not post unrelated questions or large chunks of code.
  • Please do not engage in flaming/abusive behaviour.
  • Comments that contain advertisments or appear to be created for the purpose of link building, will not be published.

Archives Blog Listing