使用 Apache .htaccess 设置 PHP $_SERVER 值 ($_SERVER['something'])

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/612228/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 17:21:13  来源:igfitidea点击:

Setting a Php $_SERVER value ($_SERVER['something']) using Apache .htaccess

phpapache.htaccess

提问by SeanDowney

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

是否可以使用 .htaccess 或其他 apache 功能在 php 数组 $_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.

我意识到我问了很多问题,答案是否定的,所以请随意说出来。

回答by Gumbo

Try the SetEnvdirective:

尝试SetEnv指令

SetEnv is_special foobar