LiteSpeed Support Forums

LiteSpeed Support Forums (http://www.litespeedtech.com/support/forum/index.php)
-   General (http://www.litespeedtech.com/support/forum/forumdisplay.php?f=25)
-   -   Setting environment variables in .htaccess (http://www.litespeedtech.com/support/forum/showthread.php?t=5929)

Gerry 05-16-2012 07:05 AM

Setting environment variables in .htaccess
 
It seems environment variables don't work as expected on LiteSpeed and aren't compatible with the way Apache does things.

I have this, which works on Apache:

Code:

SetEnvIf Request_URI "^/path/to/admin.*$" adminUri

AuthName "Password protected"
AuthType Basic
AuthUserFile ./.htpasswd
Require valid-user

Order Deny,Allow
Deny from all
Allow from env=adminUri
Satisfy any

Searching around brought up that LiteSpeed doesn't handle SetEnvIf at all and that it should be done with rewriterules. The problem is that it doesn't work either:

Code:

RewriteRule ^/path/to/admin - [E=AppDisablePasswordProtect:1]

AuthName "Password protected"
AuthType Basic
AuthUserFile ./.htpasswd
Require valid-user

Order Deny,Allow
Deny from all
Allow from env=AppDisablePasswordProtect
Satisfy any

Furthermore, setting an environment variable and using it in, for example, PHP doesn't work either:

Code:

RewriteRule (.*) - [E=FOO:BAR]
PHP Code:

<?
print_r
($_ENV);

Any pointers on how to solve these two issues?

webizen 05-16-2012 01:35 PM

Adding Env should be working in LSWS. You can enable rewrite logging to verify by adding 'RewriteLogLevel 9' in httpd.conf and look for [REWRITE] entries in error_log.

However, the added env would not reflect in $_ENV but $_SERVER.

For your case, a workaround is to create .htaccess in folder /path/to/admin to allow access:
Quote:

Allow From All
Satisfy Any


All times are GMT -7. The time now is 08:15 PM.