doa24uk Posted September 19, 2007 Share Posted September 19, 2007 Hi guys, Ok here's the deal. I've set up my htaccess so that any file requests to the 'files' folder with teh extension .txt or .txt2 get redirected to the script dl.php RewriteEngine on RewriteRule (.*)(txt|txt2)$ /files/dl.php [QSA] Thats working fine, now I need my dl.php to print out the filename the request came from. For example test.txt I can't figure out which variable to use - PHP_SELF prints '/files/dl.php' and HTTP_REFERER prints nothing. Anyone figure this out? Quote Link to comment Share on other sites More sharing options...
ki Posted September 19, 2007 Share Posted September 19, 2007 what I would do is setup a mysql database and use the GET function, like: dl.php?id=$1, and save the files that are in the directory to special ids Quote Link to comment Share on other sites More sharing options...
remlabm Posted September 19, 2007 Share Posted September 19, 2007 try this: RewriteRule (.*)(txt|txt2)$ /files/dl.php?file=$1$2 [QSA] in your dl.php $_GET[file] Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted September 19, 2007 Share Posted September 19, 2007 Why not force all links to contain the get variable of the current page/previous pages as need, then you have the route they took to get there, however this won't work for a direct linking in. such as a href="page.php?refer=<?php echo$_SERVER['self';?> so when they click it has the page they came from on it. 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.