This site is now 100% read-only, and retired.

XML logo

Dealing with Bandwith Theft
Posted by ajt on Wed 18 Oct 2006 at 20:43
Tags: ,

I run a few web sites. I don't care if people copy any images off them to use on their own site. I don't mind if they use one of my own images to link back to my site. I do care if they just use an image on their site because they are to lazy to copy the image or to save thair bandwidth.

A friend suggested an Apache re-write rule to prevent it happening. After a tweak, I've found it most useful, I just need to wait long enough to take effect.


RewriteEngine on
RewriteCond     %{REQUEST_FILENAME} \.(gif|jpe?g|png)$       [NC]
RewriteCond     %{HTTP_REFERER}     !^$
RewriteCond     %{HTTP_REFERER}     !(www\.)?domain\.com     [NC]
RewriteCond     %{HTTP_REFERER}     !google\.                [NC]
RewriteCond     %{HTTP_REFERER}     !search\?q=cache         [NC]
RewriteRule     (.*)                -                    [F,NC,L]

UPDATE: Note that domain.com means your domain.

 

Comments on this Entry

Re: Dealing with Bandwith Theft
Posted by Anonymous (85.221.xx.xx) on Wed 18 Oct 2006 at 22:52
Ok. I must be pretty stupid. Pasted the script in my .htacces and all my images stopped working when accessing my own page.

[ Parent ]

Re: Dealing with Bandwith Theft
Posted by jonesy (210.185.xx.xx) on Thu 19 Oct 2006 at 05:52
[ View Weblogs ]
Did you forget to change the line with domain.com to your own domain?
-jonesy

[ Parent ]

Re: Dealing with Bandwith Theft
Posted by ajt (204.193.xx.xx) on Thu 19 Oct 2006 at 09:37
[ View Weblogs ]
Ah, yes, it seems obvious but I did forget to mention it. You need to put your domain in that line...

I should have explained that better, I did the exactly the same, pasted it in from my friends web site without changing anything and it didn't work for me initially either!

--
"It's Not Magic, It's Work"
Adam

[ Parent ]

Re: Dealing with Bandwith Theft
Posted by sabin (213.94.xx.xx) on Wed 25 Oct 2006 at 12:27
[ View Weblogs ]
where do you put the script in? I added it to my other rules in /etc/apache2/sites-available/default but it doesn't work. What if if I run a few sites on that server?

greets

./sabin -s

[ Parent ]

Re: Dealing with Bandwith Theft
Posted by ajt (84.12.xx.xx) on Wed 25 Oct 2006 at 18:56
[ View Weblogs ]
It depends on exactly how you configured you Apache server, and which version you have.

First you need to make sure that the ReWrite engine is available for your version of Apache. Either it's dynamically loaded (.so) or it's been statically compiled into Apache.

Assuming it's available (dynamically or statically), you then need to tell Apache to use the ReWrite engine. You can do this globally in the master configuration file, or in my example in the .htaccess file of the graphics directory.

Apache is well documented, see also:
* http://httpd.apache.org/docs/
For everything you wanted to know and more.

* http://www.debian-administration.org/articles/136
This should get you going, it's all about mod_rewrite

--
"It's Not Magic, It's Work"
Adam

[ Parent ]