Restricting off-site downloading

Status
Not open for further replies.

feros

New member
Sep 26, 2006
142
10
0
This is probably the newbliest question ever, but I'm not a coding guy ;)

I just bought a site that has a TON of traffic coming in through links on other sites going directly to files rather than to pages. What I'd like is a script (I assume .htaccess script?) that redirects people coming from other websites directly to files away from those files and instead to the pages on which those files are hosted. Get me?

So for example:

www.example.com/file.exe

would redirect to

www.example.com/downloads.php (on which file.exe is available for download)
 


Your .htaccess would look like the line below. You would need one entry for every file they are hotlinking though.

Code:
redirect 301 /file.exe http://www.example.com/download.php

Edit: Also you would need to move/rename all those files. If you don't, it would be a circular reference. Everytime you try to download a file, it would redirect to the download page.
 
Yea but if I renamed them then wouldn't people just be able to directly link to the new, renamed files?
 
Disregard my post above, I mis-read your question.

As you can see, I've had photo-stealing weasels on my mind a lot lately.
 
palms is half right though. You do need to check the refer in your htaccess. If the refer isn't a page on your site then redirect to download.php. I don't know htaccess well enough to write something like that but I know it can be done.
 
Status
Not open for further replies.