Web Hosting Talk







View Full Version : Protecting Images with .htaccess & slowdown


NVB
12-24-2001, 04:04 PM
I am having a problem with people hot linking to images. I am thinking about adding the following statement to some dir level .htaccess files.

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://www.my_domain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://my_domain.com/.*$ [NC]
RewriteRule .*\.jpg$ - [F]

I believe this will require that all JPG files within a certain directory be reffered from my domain. Any referrals that are not withing my domain will cause an error. I have a few related questions:

1. Will this work? Is there a better way to achieve the desired results?

2. Sometimes visitors IP addresses are not logged. Are http_referers also sometimes unknown? If a visitor's referer is unknown, then will that visitor be unable to view pictures?

3. Will this addition to the .htaccess file cause a significant amount of slowdown?

Chicken
12-24-2001, 07:03 PM
1. It should.
2. http_referers not know should be an issue if they are comgin from a page on your site.
3. It shouldn't.

ho247
12-24-2001, 07:34 PM
NVB, this is the best solution in tackling hot linkers. Chicken has answered your questions really... but I wanted to add that it certainly wouldn't slow down the website.

Alan

bobcares
12-27-2001, 03:03 PM
I'm not sure if I'm correct or not ( i haven't done programming for some time now... :( )
I think one can change the HTTP_REFERER with a software like curl.
So if they are using a perl script or php script to call these images they may be able to call it without any problems...

Have a great day :)

regards
amar

priyadi
12-27-2001, 04:00 PM
Originally posted by bobcares
I'm not sure if I'm correct or not ( i haven't done programming for some time now... :( )
I think one can change the HTTP_REFERER with a software like curl.
So if they are using a perl script or php script to call these images they may be able to call it without any problems...


That's true. However the point is to prevent other people to make link to images like this:


<img src="http://example.net/coolimage.jpg">


It would add unnecessary bandwidth to example.net. That will work because every major browser emit proper Referer header on each request.

Kevin2001
02-05-2002, 01:01 PM
Hey will this work for multimedia files? I have a big problem with other sites hot linking to .rm files and I'm paying the bill.

Thanks - Kevin

priyadi
02-05-2002, 01:55 PM
Originally posted by Kevin2001
Hey will this work for multimedia files? I have a big problem with other sites hot linking to .rm files and I'm paying the bill.

Thanks - Kevin

Sure. Why not? A multimedia file is only another file with different extension.

unclstevel
02-05-2002, 03:32 PM
Some great scripts can be found for free that will do exactly what you're looking for. Try:

http://cgi.resourceindex.com/Programs_and_Scripts/Perl/

another great way to stop pic leaching/stealing:

http://www.pickeeper.com/

Steve

priyadi
02-05-2002, 05:05 PM
Originally posted by unclstevel
Some great scripts can be found for free that will do exactly what you're looking for. Try:

http://cgi.resourceindex.com/Programs_and_Scripts/Perl/

another great way to stop pic leaching/stealing:

http://www.pickeeper.com/

Steve

Keep in mind it won't entirely stop people from downloading the images. A knowledgeable and determined leecher will figure out a way to circumvent it. My guess is just by looking at the URL pattern, making a list of available images and half an hour crafting a perl script, a leecher will be able to download all the protected images.

Kevin2001
02-06-2002, 03:49 AM
Originally posted by priyadi


Keep in mind it won't entirely stop people from downloading the images. A knowledgeable and determined leecher will figure out a way to circumvent it. My guess is just by looking at the URL pattern, making a list of available images and half an hour crafting a perl script, a leecher will be able to download all the protected images.


Well, if I can cut out 90% of the hot links than I'm happy. Hopefully there's only 10% that would spend the time to circumvent the script. :)

Thanks,
Kevin

Chicken
02-06-2002, 02:01 PM
Originally posted by unclstevel
another great way to stop pic leaching/stealing:

http://www.pickeeper.com/

Steve
I took a quick look at this one, as you said for the majority of people, that script seems to do the trick.