views:

20

answers:

1

I have a directory full of files.

Originally people were allowed to direct link to these files. Now i would like to run all files through a php file first.

Could someone help me with the .htaccess needed to do that? The phpfile used to handle the downloads will be called download.php and it will have a get variable called $ref

So i need noob.com/games.zip to goto noob.com/download.php?ref=games.zip BUT still retaining the url of noob.com/games.zip

Thanks!

+1  A: 

This should do the job for you:

RewriteEngine On
ReWriteRule ^(((?!download.php).)*)$ /download.php?ref=$1 [L]

...and this is if you want to keep other parameters also...

RewriteEngine On
ReWriteRule ^(((?!download.php).)*)$ /download.php?ref=$1&%{QUERY_STRING} [L]
maraspin