简体   繁体   English

如何在.htaccess文件中获取APPLICATION_ENV?

[英]How to get APPLICATION_ENV in .htaccess file?

How to get APPLICATION_ENV and other custom variables in .htaccess file? 如何在.htaccess文件中获取APPLICATION_ENV和其他自定义变量?

$_SERVER: $ _SERVER:

[
    'HTTP_HOST' => 'xx.example.com'
    'HTTP_X_GATE_HOST' => 'xx.entrance.com'
    'APPLICATION_ENV' => 'development'
]

This works fine: 这工作正常:

RewriteCond %{HTTP_HOST} xx.example.com
RewriteRule ^.*$ /index-dev.php [NC,L]

But: 但:

RewriteCond %{APPLICATION_ENV} development
RewriteRule ^.*$ /index-dev.php [NC,L]

just won't work. 就是行不通。

RewriteCond %{ENV:APPLICATION_ENV} development
RewriteRule ^.*$ /index-dev.php [NC,L]

This won't work neither... Please help :| 这也不起作用...请帮助:|

You just need to change: 您只需要更改:

SetEnv APPLICATION_ENV "development"

with this line: 用这一行:

SetEnvIf Host ^ APPLICATION_ENV=development

Env variable created by SetEnvIf are available for mod_rewrite to evaluate later, which is not the case with SetEnv due to sequencing of loading of Apache modules. SetEnvIf创建的Env变量可供mod_rewrite稍后评估,对于SetEnv则不是这种情况,这是由于Apache模块的加载顺序所致。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM