Header doesn't support env. Header set TEST_name "TEST_VALUE" env=!TESTenv

xGZx

New Member
#1
Hello,

I need to set the Header depending on whether the file exists or not, I don't want to use php to set the Header when the file exists.

The example below should work but for some reason it doesn't work in openlitespeed, please help.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L,E=TESTenv:1]

Header set TEST_name TEST_VALUE env=!TESTenv

Unfortunately in openlitespeed the Header TEST_name is always set regardless of whether TESTenv exists or not, so it doesn't work properly becaouse it should be set only if TESTenv doesn't exist.

Of course I do it in Context. TESTenv is set correctly, i'm checking TESTenv in this way:
Header set TESTenv %{TESTenv}e
gives in Headers:
if file doesn'n exists (RewriteRule . index.php [L,E=TESTenv:1] works)
TESTenv: 1
if file exists:
TESTenv:

Header help in openlitespeed shows:
Syntax: [Header]|RequestHeader [condition] set|append|merge|add|unset header [value] [early|env=[!]variable]
So env should be supported, it looks like a bug.
 
Last edited:

xGZx

New Member
#3
Hello,

Unfortunately, no one has responded to the problem I described.

It seems that there are no OpenLiteSpeed developers on this forum, as they would know what to reply if they were here.

Anyway, today I had some free time and reviewed the source code of OpenLiteSpeed 1.8.1, and unfortunately, it does not handle env=.

I took some time to add proper handling for env=MY_VAR / env=!MY_VAR, and now it works correctly, just like in Apache.


If anyone needs it, I can send a compiled openliyespeed file with env= support or provide the source files with the corrected code.
If any OpenLiteSpeed developer is interested, I can share the source code to be added to the official OpenLiteSpeed distribution.

Greetings
Grzegorz Sławecki
 
Top