首页 > 解决方案 > PHP:用于 litespeed 的 x-sendfile

问题描述

我将以下代码用于 apache:

$file = 'a.mp3';
$mime = mime_content_type($file);
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Content-type: ' . $mime);
header('Content-Length: ' . filesize($file));
header('X-Sendfile: ' . $file);
exit();

但是新的服务器管理员要求我将其更改为 litespeed 版本

如何 ?

标签: phpx-sendfilelitespeed

解决方案


试试下面的代码

$file = 'https://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4';
$mime = 'video/mp4';
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Content-type: ' . $mime);
header('Content-Length: ' . filesize($file));
// header('X-Sendfile: ' . $file);
header('X-LiteSpeed-Location:' . $file);

exit();

推荐阅读