phpx-sendfilelitespeed

PHP: x-sendfile for litespeed


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 ?


Solution

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