Nix bandwidth thieves

One of my friends just asked me how to stop people from linking your images onto their web sites. I’ve been blocking people from doing this for a while using a mod_rewrite script that my friend came up with off the top of his head a while ago. Since I couldn’t find anything related to this within the blog circles I read, I figured this may be handy for anyone else to use.

So, if you’re looking to keep people from stealing your bandwidth by “borrowing” your images (or other files) and are tired of IP blocking them, this should come in fairly handy to you.

Just add the below text to your .htaccess file or if you run your own Apache server, add it to your httpd.conf file. The way I set this up, it blocks most image formats from being hot linked off your server. I have two servers in there for my own reasons. You simply need to add one server if you are using one domain, otherwise to allow others just add another RewriteCond with the new domain name following the same format.

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?lascivious.org(/).*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?lascivious.org(/).*$ [NC]
RewriteRule .*\.(gif|jpg|jpeg|bmp|png)$ – [F,NC]

Hope this helps someone!

2 replies on “Nix bandwidth thieves”

Comments are closed.