I want to return the content of "download.p开发者_运维问答hp?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();
精彩评论