[solved] htaccess SetEnv

Discussion in 'Apache Migration/Compatibility' started by zolll, Apr 20, 2013.

  1. zolll

    zolll New Member

    Hello,

    Due to the increased number of users on our web page, we have to migrate it from Apache to Litespeed. However, there is one problem: we use SetEnv commands within htaccess file in order to set some environment variables, for ex:

    SetEnv USER user1

    This works well in Apache, but not in Litespeed - it has no effect. We have tried lots of other commands using RewriteRules, such as:

    RewriteRule ^ - [E:USER=user1]
    RewriteRule . - [E:USER=user1]
    RewriteRule ^(.*) [E:USER=user1]
    RewriteRule ^(.*) - [E:USER=user1]

    ... and so on, but none of them sets the environmental variables. Obviously I do call "RewriteEngine On" before calling RewriteRule commands.

    I can list all the environmental variables using phpinfo() call, but none of the entries within .htaccess sets any of the variables. I can set these directly within the php code ($_SERVER['USER'] = "user1"; ) and it works fine.

    I have looked all over the internet and couldn't find a solution that works from the .htaccess. Can you advise please?

    Thanks!
    Last edited by a moderator: Apr 22, 2013
  2. NiteWave

    NiteWave Administrator

  3. zolll

    zolll New Member

    Not working

    Under Apache the following line works perfectly:
    RewriteRule ^(.*) - [E:USER=user1]

    Under Litespeed it doesn't set anything.

    I also tried your suggestion, that doesn't set the variable either.

    Any other suggestions?
  4. NiteWave

    NiteWave Administrator

    I did test on
    which in document root .htaccess

    then access
    http://192.168.2.101/phpinfo.php

    _SERVER["USER"] user1

    is there. so it works as expected.

    please check
    AllowOverride
    setting in httpd.conf for this virtual host.
  5. zolll

    zolll New Member

    It works!

    I've tried this and it worked indeed, thanks for the help!

Share This Page