Kar*_*arl 5 apache .htaccess environment-variables
我想知道是否有一种方法可以将环境变量(或类似变量)与if语句一起使用,以打开和关闭某些内容,例如display_errors,modpagespeed。
因此,例如:
SetEnv DISPLAY_ERRORS on
<If "DISPLAY_ERRORS == on">
php_flag display_errors on
</If>
<If "DISPLAY_ERRORS == off">
php_flag display_errors off
</If>
Run Code Online (Sandbox Code Playgroud)
我已经花了很长时间寻找这种东西,但是我无法发现任何能做到这一点的东西。这有可能吗?
我正在寻找一种使用PHP编辑htaccess的简便方法,但是与其将块写入htaccess,还不如直接将“ on”和“ off”值更改为更容易,并且也更容易将其显示为单选按钮在我的应用程序中。
我们很想写这个:
#SetEnvIf Request_URI "^" DISPLAY_ERRORS=off
SetEnv DISPLAY_ERRORS off
<If "-T env('DISPLAY_ERRORS')">
php_flag display_errors off
</If>
<Else>
php_flag display_errors on
</Else>
Run Code Online (Sandbox Code Playgroud)
但似乎<If>是evalued 之前的任何SetEnv(If)。
注意,变量的值可能取决于对其进行评估的请求处理的阶段。例如,
<If >指令中使用的表达式会在验证完成之前求值
我想到的另一种工作方法是:
<IfDefine DISPLAY_ERRORS>
php_flag display_errors on
</IfDefine>
<IfDefine !DISPLAY_ERRORS>
php_flag display_errors off
</IfDefine>
Run Code Online (Sandbox Code Playgroud)
然后-DDISPLAY_ERRORS以显示错误的参数启动Apache,或者对于Apache> = 2.4,Define DISPLAY_ERRORS在virtualhost配置中添加a 。
| 归档时间: |
|
| 查看次数: |
6738 次 |
| 最近记录: |