How do you use SetEnv to read variables in Apache?

徘徊边缘 提交于 2019-12-12 20:42:44

问题


I want to set an env variable that has the DOC_ROOT info but nothing

SetEnv PROJECT_BASE %{ENV:DOC_ROOT}
SetEnv LAYOUT_HOME  %{ENV:PROJECT_BASE}"/html/app/wordpress/"

and then be able to access LAYOUT_HOME in php

How can I do this?


回答1:


Variables are accesible via :

$_SERVER["LAYOUT_HOME"] and $_SERVER["PROJECT_BASE"] global variable.

A simple test if to execute the next command in php

<?php phpinfo(); ?>

and check if the variable is present and is defined.

If not, then may be exist some restricting in the php installation ( for example in a share ambiance - sharedhosting)




回答2:


So far it's not possible. All you can do is to set request headers with RequestHeader. So you'll have you variable in environ but with "HTTP_" prefix.



来源:https://stackoverflow.com/questions/5010660/how-do-you-use-setenv-to-read-variables-in-apache

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!