How to force ssl in codeigniter?

前端 未结 3 1732
面向向阳花
面向向阳花 2020-12-05 11:47

I am using codeigniter 3. How do I force SSL connection to my web pages so that all the pages are loaded with the green padlock icon beside it?

Note: How can I do th

3条回答
  •  长情又很酷
    2020-12-05 12:23

    Codeigniter(GAE): best practice to redirect http to https in the ssl.php file:

    function force_ssl() {
        $server=$_SERVER["SERVER_NAME"];
        $uri=$_SERVER["REQUEST_URI"];
        if ($_SERVER['HTTPS'] == 'off') {
            redirect("https://{$server}{$uri}");
        }
    }
    

提交回复
热议问题