Using server variables in php_value

Hi,

I’m working on a system that uses auto_prepend_file to include a global config file. I sometimes work in a different location, where the files are in a different place. Furthermore, I would like the project to be flexible, and easy to install in a directory structure of the user’s choice.

Therefore, I would to use the server variable DOCUMENT_ROOT in the php_value. Something like this;


php_value auto_prepend_file %{DOCUMENT_ROOT}/myproject/config.php

Is this possible at all?

:blush: I’m not sure why I was blind to the obvious two+ years ago but %{DOCUMENT_ROOT} is a “server internal” variable so $_SERVER[‘DOCUMENT_ROOT’] would be how PHP would access that value.

Regards,

DK

Yes, but the OP was calling php_value, which is Apache syntax, not PHP.

I know this is a wicked old thread, but it mislead me before, so here goes:

You cannot use a path relative to the DocumentRoot in an .htaccess file. However, you can use a file relative to the ServerRoot. This doesn’t really help the original poster, but hey, “Nope” is an answer too.

Ize,

I don’t see what’s wrong with it - except that you could remove %{DOCUMENT_ROOT} with the same effect (and it would be more correct, i.e., have a better chance of working).

Regards,

DK

Hm that’s odd… PHP gives me this fatal error with that line:


Fatal error: Unknown: Failed opening required '%{DOCUMENT_ROOT}/path/to/inc.php' 

In other words, the DOCUMENT_ROOT variable is not translated to the actual document-root. :frowning:

Ize,

Okay, then definitely REMOVE the %{DOCUMENT_ROOT) from the code. Remember, this is a web server so the leading / IS the DocumentRoot!

Regards,

DK