无法从htaccess中的SetEnv变量获取$ _SERVER中的值

时间:2018-07-17 05:36:09

标签: php .htaccess codeigniter cpanel mod-env

我已经使用 SetEnv 在.htaccess文件中设置了一些变量,但是使用 $ _ SERVER 的php文件却无法获取。

这是htaccess的代码:

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
AddDefaultCharset utf-8

# Enviroment variables; change these to match server configurations
SetEnv ENVIRONMENT development
SetEnv APP_DB_HOSTNAME localhost
SetEnv APP_DB_USERNAME root
SetEnv APP_DB_PASSWORD root
SetEnv APP_DB_NAME root_pro
SetEnv APP_ENC_KEY xxxxx-xxx-xxx

但是我没有在 $ _ SERVER ['ENVIRONMENT'] 中获得价值。请给它建议。

注意:这在我的实时服务器中不起作用,并且已经启用了 mod_env

谢谢。

1 个答案:

答案 0 :(得分:0)

确保将AllowOverride设置为FileInfo(或All):

AllowOverride FileInfo

在相关目录中。

另外,suexec可能会删除环境变量。