PDA

View Full Version : Image Hotlinking problem - Help Please


DarkDelight.net
Sun 10th Aug '03, 11:46am
I have a slight hotlinking problem which I can't quite seem to pin down.

In my forums images directory there is a .htaccess file redirecting requests from other sites (or so I thought) to another image.

This appears to work fine when I try to post here with one of those images but it breaks down when I use a local file on my computer to do it.

Could you try it and see what happens when you call an image in a html document on your desktop?

This is the image linked to in this post:
<img src="http://forums.darkdelight.net/images/5stars.gif">
<img src="forums.darkdelight.net/images/5stars.gif">

When I try this, the first instance shows the image without redirecting and the second is broken.


Here is a call to the same 5stars image which should be redirected.

http://forums.darkdelight.net/images/5stars.gif

This is what I have in the .htaccess

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://12.345.678.90.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://forums.mydomain.tld.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.mydomain.tld.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://mydomain.tld.*$ [NC]
RewriteRule .*\.(gif|GIF|jpg|JPG|png|PNG|jpe|JPE|jpeg|JPEG|bmp |BMP |php|PHP)$ http://www.mydomain.tld/naughty_img.ext [R,L]
</IfModule>



Does anyone know why this is not working correctly?

Thanks.

phill2003
Sun 10th Aug '03, 12:49pm
sorry to jump on your post, but would that work on mine as well ?

Mijae
Sun 10th Aug '03, 12:51pm
I want to do the same with my site, anyone know a good url to a good how-to?

ffaBen
Sun 10th Aug '03, 12:57pm
For Security reasons browsers won't send the url to the html file on your desktop.

And
<img src="forums.darkdelight.net/images/5stars.gif">

That needs the http:// on the front to make it goto your site, if someone did it without the http:// on theirs it'd try taking them to http://www.theirdomain.tld/forums.darkdelight.net/images/5stars.gif

DarkDelight.net
Sun 10th Aug '03, 1:04pm
For Security reasons browsers won't send the url to the html file on your desktop.

Right. So this is working as it's supposed to then.


And
<img src="forums.darkdelight.net/images/5stars.gif">

That needs the http:// on the front to make it goto your site

I tried it both ways as the first wasn't working, or at least I thought it wasn't.

Thanks. That's cleared it up a lot.

Icheb
Sun 10th Aug '03, 2:01pm
"Could you try it and see what happens when you call an image in a html document on your desktop?"

I don't understand what you want to do. If you reference the file correctly, it will behave the exact same way as if the file were online.

"For Security reasons browsers won't send the url to the html file on your desktop."

Of course it sends the url. There is no security issue involved, you can't access that file from the outside anyways.

DarkDelight.net
Sun 10th Aug '03, 2:06pm
"Could you try it and see what happens when you call an image in a html document on your desktop?"

I don't understand what you want to do. If you reference the file correctly, it will behave the exact same way as if the file were online.


Write a html document and save it locally on your computer.
Somewhere in that document try to display the image http://forums.darkdelight.net/images/5stars.gif
It should be redirected to http://www.darkdelight.net/images/donteventhinkaboutit.gif but it is not.
When I use the img bbcode to show the 5stars image here it is redirected as expected.

phill2003
Sun 10th Aug '03, 2:06pm
i just tried that htaccess thingy on my site it worked that well i couldnt get any images on the forum either lol :D

DarkDelight.net
Sun 10th Aug '03, 2:09pm
i just tried that htaccess thingy on my site it worked that well i couldnt get any images on the forum either lol :D

You probably did not correctly enter the url of your forums to allow it to use the images.

ffaBen
Sun 10th Aug '03, 2:32pm
Of course it sends the url. There is no security issue involved, you can't access that file from the outside anyways.

Rigghhht! (http://www.google.com/search?hl=en&lr=&ie=UTF-8&oe=UTF-8&safe=off&q=access+%22local+file+system%22+Internet+Explorer +Security&btnG=Google+Search)

Faruk
Thu 14th Aug '03, 8:37pm
As far as I know, it's simply impossible to prevent 'hotlinking' against locally stored html pages (possibly on Windows only, though).

However, it's not something you should worry about. What you want to prevent is people using them in sites and thus stealing your bandwidth. Someone who has a page locally and uses your image will load it once, but he or she could just as easily create the same bandwidth-use by just looking at it online. They still can't use it in any live site. Hence, nobody else can see it through that file on their HD.

Thing is, running an HTML page on your computer locally, is running an HTML page without it being on a server. Even if you run apache locally, you are not on a DNS-zoned server (unless your computer is actually zoned and accessible on the 'Net through an ip or domain), and thus you will NOT have a server in your referrer info. Apache, however, fails to recognize this as an empty referrer string, and thus the image loads fine.