views:

696

answers:

2

Is it possible using .htaccess or other apache powers to set a custom server value in the php array $_SERVER.

for example

if($_SERVER['is_special']) {
    echo "Yeah for us!";
} else {
    echo "No you fool!";
}

I realize I ask a lot of questions that the answer is no so feel free to say so.

A: 

The short answer is no, however what exactly are you trying to accomplish?

zodeus
I basically need to pass data from an htaccess file to php
SeanDowney
What information?
cletus
I'm symbolically linking a home directory to another folder in which displays a webpage. I'm doing this rather than changing the document root via apache which is ugly. Since php doesn't know about the sym link I was hoping to pass in a custom var to php and let it know it's original folder.
SeanDowney
+4  A: 

Try the SetEnv directive:

SetEnv is_special foobar
Gumbo
There it is! 'is_special' => string 'foobar' (length=6)
SeanDowney
Note that you need mod_env to do this.
Gumbo
Try and avoid polluting the $_SERVER variable. I would recommend creating some sort of Registry class if you want to store global data.
zodeus