How to use X-Sendfile or X-Accel-Redirect in LiteSpeed 4.1.3

b0ngma01

Active Member
#1
How to use X-Sendfile or X-Accel-Redirect in LiteSpeed 4.1.13

Dear Staff,

I've installed LSW 4.1.13 but i have a question is: How to use X-Sendfile or X-Accel-Redirect?
I've read your wiki at http://www.litespeedtech.com/support/wiki/doku.php?id=litespeed:wiki:feature:internal_redirect, and i try with code:
PHP:
<?
header("Content-type: application/java-archive");
header("X-Sendfile: HOT_GAME.jar");
?>
But download file is empty.
EX: My domain is: http://xinh.im, and direct download org file is http://xinh.im/HOT_GAME.jar , php file X-Sendfile is: http://xinh.im/t.php, when i download with http://xinh.im/t.php it response file is empty.

Please help me,
 
Last edited:

NiteWave

Administrator
#4
my local tests shows
PHP:
<?php
header("X-LiteSpeed-Location: /HOT_GAME.jar");
?>
works. will prompt you to down t.php

accessing domain.com/t.php is same to access domain.com/HOT_GAME.jar directly.

my tests also shows
header("Content-type: application/java-archive");
will be ignored. however, since the built-in MIME is "application/java-archive", so it does have a MIME type.

you can simply test it with
"curl -I domain.com/t.php" on a linux terminal.
 
Last edited:

b0ngma01

Active Member
#5
my local tests shows
PHP:
<?php
header("X-LiteSpeed-Location: /HOT_GAME.jar");
?>
works. will prompt you to down t.php

it's same behavior when you access domain.com/HOT_GAME.jar directory.

my tests also shows
header("Content-type: application/java-archive");
will be ignored. however, since the built-in MIME is "application/java-archive", so it does have a MIME type.

you can simply test it with
"curl -I domain.com/t.php" on a linux terminal.
Okay, i've got it ;)
Thank you so much!
 

b0ngma01

Active Member
#6
Dear NiteWave,

I have a question, please help me. I see at http://www.litespeedtech.com/support/wiki/doku.php?id=litespeed:wiki:feature:internal_redirect how to Protect folder, but i think i don't understand how to protect all file, folder & subfolder.
EX: I have http://domain.com/data/subfolder/file.mp3
php file download is http://domain.com/dl.php
So, How to protect with .htaccess ? Here is my .htaccess
Code:
RewriteEngine On
RewriteCond %{ORG_REQ_URI} ^/data/
RewriteRule ^/data/ - [R=403,F]
But it not work.
 

NiteWave

Administrator
#7
there are 2 kinds of rewrite rules: per directory and per server.
the one you post is per server rule. in .htaccess, should use per directory.

in this case, please try following:
Code:
RewriteEngine On
RewriteCond %{ORG_REQ_URI} ^/data/
RewriteRule ^data/(.*) - [R=403,F]
 
Top