CodeIgniter Forums
Improvement for ENVIRONMENT definition - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17)
+--- Thread: Improvement for ENVIRONMENT definition (/showthread.php?tid=63387)



Improvement for ENVIRONMENT definition - ComputingFroggy - 10-25-2015

Hi,

I am running CI 3.0.2 on a shared host server.

I've defined CI_SERV in .htacces, like this:
Code:
SetEnv CI_ENV "testing"
However, looking at phpinfo I get a variable REDIRECT_CI_ENV and not CI_ENV !

So I would suggest the following modification in index.php (line 56) for next CI versions:

Code:
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : (isset($_SERVER['REDIRECT_CI_ENV'])?$_SERVER['REDIRECT_CI_ENV']:'development'));


Cheers,
[email protected]


RE: Improvement for ENVIRONMENT definition - mwhitney - 10-27-2015

From http://stackoverflow.com/questions/3050444/when-setting-environment-variables-in-apache-rewriterule-directives-what-causes

Quote:Adding the following to the start of the rewrite rules recreates the original ENV:VAR on each redirect (as well as leaving the REDIRECT_VAR versions there) if they're needed:

Code:
RewriteCond %{ENV:REDIRECT_VAR} !^$
RewriteRule .* - [E=VAR:%{ENV:REDIRECT_VAR}]