mrbuter Posted June 20, 2008 Share Posted June 20, 2008 Hey guys, I recently made a download.php file (i.e. download.php?f=file.extension). Unfortunately I made it AFTER some people have already been directly linking to the files. Is there a way I can make it so hotlinked files go to download.php?f=thenameofthefile ? I only know how to prevent hotlinking with .htaccess files and those aren't advanced enough I don't think. Any ideas? Quote Link to comment Share on other sites More sharing options...
DarkWater Posted June 20, 2008 Share Posted June 20, 2008 You can easily do that with .htaccess files. Hell, you can block all access to that entire folder by web browsers with .htaccess so that only PHP can grab the files. Quote Link to comment Share on other sites More sharing options...
mrbuter Posted June 20, 2008 Author Share Posted June 20, 2008 I know how to block access through .htaccess but can .htaccess pass the filename (of the file trying to be downloaded) onto the redirect url? Oh also one more thing, I tried limiting the script so that http referer had to be a certain site. However, is there a way to simply limit it to a domain? Because like www.site.com will work but www.site.com/index.php?s=123 won't (etc.). In short it's being too accurate! Quote Link to comment Share on other sites More sharing options...
DarkWater Posted June 20, 2008 Share Posted June 20, 2008 Can I see what your script is right now? And you can easily fake HTTP referrers, by the way. >_> Anyway, you can use mod_rewrite to get the redirection with the filename and stuff done. Quote Link to comment Share on other sites More sharing options...
corbin Posted June 20, 2008 Share Posted June 20, 2008 http://www.javascriptkit.com/howto/htaccess10.shtml As for redirecting, and passing the file name, you could do something like... RewriteEngine On RewriteRule ^/downloads/(.*)$ /download\.php\?file=$1 That would rewrite things like.... http://yoursite.com/downloads/somefile.txt to http://yoursite.com/download.php?file=somefile.txt That's entirely pointless though, as it's basically allowing direct access.... Unless you're doing some kind of check in download.php.... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.