How to set dynamic base url to https in CodeIgniter?

I am trying to use a dynamic base url in this post:

Set dynamic base url in CodeIgniter

But I used http, but now, I would like to switch to https, how can I do this? Thanks.

+4
source share
2 answers

In your config / config.php try the following:

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

You can use hookigniter hooks in pre_controller, you just change base_url http to https to replace the string and set the base url

+1
source

All Articles