Jump to content

mod_rewrite problem with tricky hotlinking


Carbunkulous

Recommended Posts

I run the site http://www.willhostforfood.com, and with the new version hot linking will be gracefully degraded too the download page.. but i'm having a slight problem..

 

I want the page too go back to the download page, even if they type the hotlink directly into the URL bar, only too actually allow them too download if they get redirected through my dl.php script. (It just uses header(location:)) ... is there anything I can do to GRACEFULLY degrade it? I know i could chmod the files low enough and then raise the permissions when the DL button is pressed, but that would stop any hot linkers completely.. I want it too go back to the DL page.

 

My current code consists of:

 

RewriteEngine on

RewriteRule ^files/([0-9])$ /files/$1/*.* [R]

RewriteRule ^files/([0-9])/$ /hotlink.php?Folder=$1

 

the folders are stored in this sort of directory

files/rand(0,1000000)/filename.fileext

 

If it is declared not from the DL page, I want it too redirect too

hotlink.php?Folder=[the rand() part]

From there I can redirect too the DL page, so don't worry about that :)

 

I don't need the actual filename, i just need which folder it is stored in...

 

any help would be appreciated..

 

 

(SOZ FOR THE REPOST-- it was in the wrong section)

So you only want people to download files from a specific php script? (dl.php)?

You also wish to prevent hotlinking so people cant just type the location of the file into the address bar?

 

I would put all the files behind the public directory, so there is physically no way to access the files from a direct link;

I would then use dl.php with a content-type Header to give the file, it would basically include it, as ou do with GD Images when displaying them without saving.

 

your "Direct Links" would become something like: dl.php?file=a697b87a087ef9c // some md5 hash maybe?

you could then use a combination of "sessions/cookies and ip+host" or (easiest, best method) auto-generated 1 time keys,to prevent them downloading more than once.

 

Hope this helps :P.

 

PS. this is an alertanate solution to your mod rewrite code. i do ot use mod rewrite but maybe someone can give you a direct solution.

So you only want people to download files from a specific php script? (dl.php)?

You also wish to prevent hotlinking so people cant just type the location of the file into the address bar?

 

I would put all the files behind the public directory, so there is physically no way to access the files from a direct link;

I would then use dl.php with a content-type Header to give the file, it would basically include it, as ou do with GD Images when displaying them without saving.

 

your "Direct Links" would become something like: dl.php?file=a697b87a087ef9c // some md5 hash maybe?

you could then use a combination of "sessions/cookies and ip+host" or (easiest, best method) auto-generated 1 time keys,to prevent them downloading more than once.

 

Hope this helps :P.

 

PS. this is an alertanate solution to your mod rewrite code. i do ot use mod rewrite but maybe someone can give you a direct solution.

 

That wouldn't degrade gracefully though.. that my entire problem, i want it too redirect too the download page if it is direct.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.