Weblog entry #56 for ajt
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
[ Parent | Reply to this comment ]
-jonesy
[ Parent | Reply to this comment ]
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 | Reply to this comment ]
[ Send Message | View sabin's Scratchpad | View Weblogs ]
greets
./sabin -s
[ Parent | Reply to this comment ]
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 | Reply to this comment ]