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

Discussion in 'Install/Configuration' started by b0ngma01, Oct 22, 2012.

  1. b0ngma01

    b0ngma01 New Member

    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: Oct 22, 2012
  2. NiteWave

    NiteWave Administrator

  3. b0ngma01

    b0ngma01 New Member

  4. NiteWave

    NiteWave Administrator

    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: Oct 22, 2012
  5. b0ngma01

    b0ngma01 New Member

    Okay, i've got it ;)
    Thank you so much!
  6. b0ngma01

    b0ngma01 New Member

    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.
  7. NiteWave

    NiteWave Administrator

    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]

Share This Page