CodeIgniter dynamic base_url

CI default configuration can only be fixed at the time of the URL, HTTP and HTTPS can not even interoperability, the following code is added to the application / config / config.php, and the original $ config [ 'base_url'] commented out, the code It is set according to the URL that users access.

$root  = (isset($_SERVER['HTTPS']) ? "https://" : "http://").$_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
$config['base_url'] = $root;
Published 18 original articles · won praise 1 · views 20000 +

Guess you like

Origin blog.csdn.net/weixin_42557486/article/details/83584513