htaccess mod rewrite files to go through php first?
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 开发者_C百科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!
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]
精彩评论