开发者

How Can I use .htaccess to return another file to the client?

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();
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜