如何使用.htaccess将另一个文件返回给客户端?

I want to return the content of "download.php?file=filename" if anybody request "filename.rar"

RewriteEngine on
RewriteRule (.*)\.rar download.php?file=$1.rar

This'll turn your server into a wide open door for anyone to grab any file they want, but... it does what you want.

<?php
    readfile($_REQUEST['file']);

Enjoy...

if(isset($_GET[file]))

 header("Location: PATH TO FILE");

OR

$filename = 'FILENAME';
$file = 'PATH TO FILE';


header("Content-Disposition:  inline; filename=".$filename);
header("Content-Type: application/octet-stream");
header("Content-Length: ".filesize($file));
header("Pragma: no-cache");
header("Expires: 0");
$fp=fopen($file,"r");
print fread($fp,filesize($file));
fclose($fp);
exit();