Web Hosting Talk







View Full Version : Hotlinking Question?


tacoX
07-18-2004, 10:56 PM
Lets say somebody links to one of the images on my site, but its not there. Is it possible to show a different image? I belive its something with .htaccess

SEATi
07-18-2004, 11:18 PM
You are right, it's done with .htaccess.

Just use a line:

ErrorDocument 404 /path/to/yourimage.jpg

The only con about this is that if someone tries to reach a non existant page will also get that image, to filter which requests should show the image you can use the <file> statement (to add file types).

zupanm
07-19-2004, 07:19 AM
i think he wants to switch an image if someone is using his..

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ http://www.mydomain.com/badimage.gif [R,L]

SEATi
07-19-2004, 02:17 PM
Originally posted by tacoX
Lets say somebody links to one of the images on my site, but its not there. Is it possible to show a different image? I belive its something with .htaccess

He says that the image isn't there, so it would return a 404. That makes me think that it's not a "how to prevent image hotlinking?" thread.

tacoX
07-21-2004, 06:21 PM
Lets say someone trys to link to:

imghst.com/uploads/tacox/lol.gif
But the file is not there. I want it to DISPLAY imghst.com/error/error.gif. (So if somebody was LINKING to /lol.gif, instead of showing an X, it shows the error.gif (lol.gif > error.gif)

Something similar to http://www.iownjoo.com (try going/linking to a bogus image/url)

SEATi
07-21-2004, 09:13 PM
zupanm: I was right :)

tacoX: Use the line I gave you in a .htaccess file on your web root

tacoX
07-21-2004, 11:00 PM
Wonder if somebody is linking a .PNG and my image is a .GIF? Will it still show?

tacoX
07-21-2004, 11:16 PM
Well - because it wont let me edit - I added the .htaccess file to my /img dir (its hosted on http://www.sitehst.com) and went to a bogus URL (http://www.imghst.com/lollol.gif) and it just said the average, 'file not found' error.