开发者

htaccess mod rewrite files to go through php first?

开发者 https://www.devze.com 2022-12-27 01:28 出处:网络
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.

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]
0

精彩评论

暂无评论...
验证码 换一张
取 消