Forum Moderators: phranque

Message Too Old, No Replies

Can I redirect a hotlinked image?

         

Kamilla

11:17 pm on Sep 13, 2003 (gmt 0)

10+ Year Member



I allow hotlinking for traffic trades so I don't have an htaccess file to block all hotlinking - only a file where I add specific domains that I don't allow to hotlink.

I read somewhere that you can redirect a hotlinked image, kinda like breaking out of frame and redirect to a different page, but I have never seen that code. Is this even possible? If so, where can I find the info how to this?

Thanks a bunch!
Kamilla

jdMorgan

11:21 pm on Sep 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Kamilla,

Welcome to WebmasterWorld [webmasterworld.com]!

This thread [webmasterworld.com] has an example of code to accomplish this in .htaccess under Apache. You can find many more examples by searching in WebmasterWorld for "hotlink" and variants of that word.

Jim

Kamilla

11:28 pm on Sep 13, 2003 (gmt 0)

10+ Year Member



Hello jdMorgan and thanks for the welcome!
However that thread doesn't answer my question. I already have working htaccess files. I was wondering if it's possible to redirect a site that are not authorized to hotlink an image to a page of my choice?

Thanks!
Kamilla

jdMorgan

4:09 am on Sep 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Kamilla,

If you mean "authorized using Apache's password authorization mechanism," then no, I don't know how you'd do that. The 401-Authorization Required exchange protocol is rather crude and inflexible. I suppose you could write your own authorization-handling script, and wrap your protected content in it.

If you just want to create a list of sites that are or are not allowed to hotlink, then the example I cited, which contains one site which is not allowed to hotlink, can serve as an appropriate starting-point example.

Ref: Introduction to mod_rewrite [webmasterworld.com]

Jim

jdMorgan

4:17 am on Sep 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Maybe the sticking point is this:

Can you redirect from an image to a document, for eaxmple from a .gif file to an .html file?

The answer here would be no, a client (e.g. browser) expects the document it requested to be served, or at least a document having a similar type (MIME-type) to the one it requested. And the client actually specifies what MIME-types it will accept in the HTTP Request header that it sends to the server.

So, you can usually get away with redirecting from, say gif to jpeg, but not from jpeg to html. The browser will get confused and just show a broken image link.

Jim