In reply to Anonymous.

This has nothing to do with your blog today, but I remember you talking about this some time ago. Where someone on ebay uses an image from your site inside of their ebay post. You were grumbling about it, so I immediately thought of you when I saw the post below on Islandnet. I don't know if you are already aware of the solution, but here goes:

Mark wrote:

What you are describing is a theft of resources, not to mention your money since you pay for bandwidth.

It is possible to prevent this with a few lines in an .htaccess file:

[code]setenvifnocase referer "^https?://(www\.)?YOURDOMAIN/" ok=1
setenvifnocase referer "^$" ok=1

order allow,deny
allow from env=ok
[/code]

The first line checks the HTTP Referer value passed along by the browser, and if it starts with your URL it sets the variable "ok" to 1. The pattern you see there is a regular expression that checks for "http", optionally followed by an 's', followed by "://", optionally followed by "www.", then your domain name, then a slash.

The second line checks for an empty referer value and it also sets the "ok" variable. This is necessary because some browsers won't pass along the referer, and without this line your images wouldn't be available to these legitimate (in most cases) visitors.

The rest of it defines a set of access rules that apply to files that end with ".gif", ".png", ".jpg", or ".jpeg". Theses rules deny access unless the "ok" variable is defined.

So if someone links your image to a site on Ebay, and a visitor views that page, their browser will request the image from here but the referer value it passes along will normally not be empty and it won't match your domain either, it'll be an ebay URL. The images will appear broken. The browser still consults our server but no file is transferred, saving bandwidth. And whoever is misusing your images will stop because nobody can see them anyway.

Note that .htaccess files only apply to the directory that they are in, and any subdirectories. You could put this at the top level of your "www" directory, but it's better to put all your images in a subdirectory and then put this .htaccess file in there. It's less work for the server.

Mark

[ Edited by Mark on May 22 2003 at 07:59 PM ]