.htaccess Environment Variables

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
mjmorgan
Forum Newbie
Posts: 3
Joined: Mon Jan 22, 2007 10:17 am

.htaccess Environment Variables

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

$_ENV not $_SERVER.

You may need to use getenv().
mjmorgan
Forum Newbie
Posts: 3
Joined: Mon Jan 22, 2007 10:17 am

Post by mjmorgan »

Tried both suggestions and still no worky. :?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

How about apache_getenv()?
mjmorgan
Forum Newbie
Posts: 3
Joined: Mon Jan 22, 2007 10:17 am

Post by mjmorgan »

apache_getenv() is not available in Apache/1.3.37.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Then I guess you're stuck. You could incorporate the information into the rewritten url.
Post Reply