Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite and php to prevent hotlinking on freehosting sites

mod_rewrite hotlinking

         

JonW88

4:41 pm on Jan 17, 2007 (gmt 0)

10+ Year Member



Hello all,

I am trying to fix a problem. I administer a number of free hosting sites. We allow users to upload multimedia files, but we don't allow hotlinking to these files from outside our network.

I am trying to use mod_rewrite rules and php to require an in-between page before end users can download the multimedia file....

If the referrer is either blank, or not from freesite.com, then I want the url:

http://www.example.com/username/mysong.mp3

to redirect to:

http://downloads.example.com/hotlink.php?file=/username/mysong.mp3

On this hotlink.php page, there will be some advertising, and a link "Click here to download mysong.mp3"

This way, we atleast have the chance to recoup the bandwidth cost for this mp3 (or other binary file).

Can anyone help? Point me to a how-to, or other forum posts from people with similar situations?

I have found a lot of solutions for preventing hotlinking altogether, but not for what I want to do.

Thank you very much for any assistance.

Sincerely,
Jon

[edited by: jdMorgan at 4:59 pm (utc) on Jan. 17, 2007]
[edit reason] Example.com [/edit]