仅当环境变量具有特定值时如何设置 Apache header
How to set Apache header only if environment variable has a certain value
我想在我的 Apache (2.4) 配置中设置 header,但前提是环境变量具有特定值。
SetEnv ENV_NAME prod
如果 ENV_NAME
不是 prod
,我如何只设置此 header?
Header set X-Robots-Tag "noindex, nofollow"
Header set X-Robots-Tag "noindex, nofollow" "expr=env('ENV_NAME') != 'prod'"
来自https://httpd.apache.org/docs/2.4/mod/mod_headers.html#header
The Header directive may be followed by an additional argument, which
may be any of:
...
expr=expression
The directive is applied if and only if expression
evaluates to true. Details of expression syntax and evaluation are
documented in the ap_expr documentation.
我想在我的 Apache (2.4) 配置中设置 header,但前提是环境变量具有特定值。
SetEnv ENV_NAME prod
如果 ENV_NAME
不是 prod
,我如何只设置此 header?
Header set X-Robots-Tag "noindex, nofollow"
Header set X-Robots-Tag "noindex, nofollow" "expr=env('ENV_NAME') != 'prod'"
来自https://httpd.apache.org/docs/2.4/mod/mod_headers.html#header
The Header directive may be followed by an additional argument, which may be any of:
...
expr=expression
The directive is applied if and only if expression evaluates to true. Details of expression syntax and evaluation are documented in the ap_expr documentation.