How to set Dynamic base url to https in CodeIgniter?

后端 未结 3 1463
独厮守ぢ
独厮守ぢ 2020-12-29 13:58

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

Set Dynamic Base Url in CodeIgniter

But I used to be use the http, but now, I would like to change to https, h

相关标签:
3条回答
  • 2020-12-29 14:33

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

    this works for me with virtualhost setup.

    0 讨论(0)
  • 2020-12-29 14:36

    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;
    
    0 讨论(0)
  • 2020-12-29 14:36

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

    0 讨论(0)
提交回复
热议问题