将域从http更改为https Zend框架

时间:2016-03-23 03:00:19

标签: php codeigniter ssl zend-framework https

我正在尝试从http切换到https,该应用正在使用zend框架。已经安装了ssl证书并且一切就绪,在config.php文件中我更改了代码

$config['base_url'] = 'http://example.com/';

到此

$config['base_url'] = 'https://example.com/';

但是,当我转到主页时,所有内容都正常加载,当我点击其他链接(example.com/player或example.com/main)时,它会为主页以外的任何链接抛出404错误。

1 个答案:

答案 0 :(得分:0)

改变
$config['base_url'] = 'https://example.com/';

$config['base_url'] = (isset($_SERVER['HTTPS']) ? "https://" : "http://") . $_SERVER['HTTP_HOST'] . preg_replace('@/+$@', '', dirname($_SERVER['SCRIPT_NAME'])) . '/';

$config['base_path'] = $_SERVER['DOCUMENT_ROOT'] . preg_replace('@/+$@', '', dirname($_SERVER['SCRIPT_NAME'])) . '/';