我为我的 CodeIgniter 站点使用了 DEV、QA 和生产环境,它们都可以正常使用 HTTPS。HTTPS 无需特殊设置即可使用它。也许您可以提供您遇到问题的 URL?
下面是我如何管理多个子域。
在“/application/config/config.php”中,将 base_url 设置为自动检测,将其留空:
$config['base_url'] = '';
我假设您的网址是:
要管理不同的环境,请打开根目录下的 index.php 并添加:
// This sets the environment based on the subdomain
$domain = explode('.', $_SERVER['HTTP_HOST']);
switch($domain[0])
{
case 'dev':
$env = 'dev';
break;
case 'qa':
$env = 'qa';
break;
default:
$env = 'production';
break;
}
define('ENVIRONMENT', $env);
// Error reporting
if (defined('ENVIRONMENT'))
{
switch (ENVIRONMENT)
{
case 'dev':
error_reporting(E_ALL);
ini_set("display_errors", 1);
break;
case 'qa':
case 'production':
error_reporting(0);
break;
case 'production':
error_reporting(0);
break;
default:
exit('The application environment is not set correctly.');
}
}
如果您有数据库,请将'/application/config/database.php' 设置为:
// Use the respective DB based on the domain name
switch(ENVIRONMENT){
case 'dev':
$active_group = 'dev';
break;
case 'qa':
$active_group = 'qa';
break;
default:
$active_group = 'production';
break;
}
// setup domain specific DB's
$db['dev']['hostname'] = 'mysql.stabletransit.com';
// etc..
$db['qa']['hostname'] = 'mysql.stabletransit.com';
// etc..
$db['production']['hostname'] = 'mysql.stabletransit.com';
// etc..