Page 1 of 1

.htaccess Environment Variables

Posted: Mon Jan 22, 2007 10:59 am
by mjmorgan
Hoping someone can help me with this problem. I'm trying to pass a variable with a RewriteRule in my .htaccess file using this technique:

RewriteRule foo bar [E=VAR:VAL]

I refer to the variable on the resulting page using:

<? php
echo $_SERVER["VAR"];
?>

and get no results. I've used phpinfo() and find that the variable doesn't show up.

I have also tried this:

<? php
echo $_SERVER["REDIRECT_VAR"];
?>

with no luck.

This, however, does return a value:

echo $_SERVER["REDIRECT_URL"];

but this wasn't the solution I was looking for.

I'm using a hosting site w/ Apache/1.3.37 and PHP Version 4.4.4

Any ideas?

--
Michael

Posted: Mon Jan 22, 2007 11:09 am
by feyd
$_ENV not $_SERVER.

You may need to use getenv().

Posted: Mon Jan 22, 2007 11:45 am
by mjmorgan
Tried both suggestions and still no worky. :?

Posted: Mon Jan 22, 2007 11:57 am
by feyd
How about apache_getenv()?

Posted: Mon Jan 22, 2007 2:39 pm
by mjmorgan
apache_getenv() is not available in Apache/1.3.37.

Posted: Mon Jan 22, 2007 2:42 pm
by feyd
Then I guess you're stuck. You could incorporate the information into the rewritten url.