如何在CodeIgniter中将动态基本URL设置为https?

问题描述:

我尝试在这篇文章中使用动态基本网址:

I try the use a dynamic base url in this post:

在CodeIgniter中设置动态基本URL

但我以前是使用http,但现在,我想改为https,我该怎么办?感谢。

But I used to be use the http, but now, I would like to change to https, how can I do so? Thanks.

在您的config / config.php中,尝试:

In your config/config.php, try this:

$root=(isset($_SERVER['HTTPS']) ? "https://" : "http://").$_SERVER['HTTP_HOST'];
$root.= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
$config['base_url'] = $root;