0

I use below code for 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();

But new server manager asked me change it to litespeed version

How ?

Computer Im
  • 85
  • 1
  • 11

1 Answers1

2

Try below code

$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();
Peter
  • 777
  • 2
  • 13
  • 34
  • Thank you, if i want force download video, how i can ? your code play direct on browser, but i want download it without play – Computer Im Jul 31 '18 at 08:23
  • @ComputerIm to force download, try `header("Content-Disposition: attachment");` – hanshenrik Jan 31 '21 at 19:19
  • According to [this](https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:config:internal-redirect) you also need a `Location` header and use the url without the protocol and domain parts. And don't forget you shouldn't send a `status` – toraman Feb 16 '21 at 23:13