Redirect to ssl in codeigniter
来源:互联网 发布:ftp连接阿里云服务器 编辑:程序博客网 时间:2024/06/03 15:38
如何让你的CI框架支持https协议呢,根据下面解释的操作设置一下就好了。
1、修改你的项目下 application/config/config.php 文件
(1)、将base_url 后面的链接加上https 如图:,
将enable_hooks设置成TRUE
2、在你的项目下 application/config/hooks.php 文件中加入以下代码
$hook['post_controller_constructor'][] = array(
'function' => 'redirect_ssl',
'filename' => 'ssl.php',
'filepath' => 'hooks'
);
3、在你的项目的application/hooks下 新建 ssl.php文件,内容如下:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');function redirect_ssl() { $CI =& get_instance(); $class = $CI->router->fetch_class(); $exclude = array(); // add more controller name to exclude ssl. if(!in_array($class,$exclude)){ // redirecting to ssl. if ($_SERVER['SERVER_PORT'] != 443) { redirect($CI->config->config['base_url'].$_SERVER['REQUEST_URI']);} } else { // redirecting with no ssl. if ($_SERVER['SERVER_PORT'] == 443) { redirect($CI->config->config['base_url'].$_SERVER['REQUEST_URI']); } }}?>
1 0
- Redirect to ssl in codeigniter
- Redirect in response to POST transaction
- How to redirect page in JavaScript
- Passenger,nginx and SSL(http redirect to https)
- nginx SSl redirect问题
- How to redirect to a Custom Page for Event Receiver in SharePoint 2010
- How to redirect to login page after cookie expires in Angular JS?
- redirect stderr in popen
- Generate CSV File and Force Browser to Download It in CodeIgniter
- date(): It is not safe to rely on the system's timezone settings in CodeIgniter
- Redirect http to https
- Redirect traffic to loopback
- Configuration to access by HTTPS with SSL in Apache HTTP
- Unknown SSL protocol error in connection to xxx:443
- Unknown SSL protocol error in connection to github.com:443
- Unknown SSL protocol error in connection to github.com:-9800
- How to create your own custom 404 error page and handle redirect in SharePoint 2007 (MOSS)?
- IO Redirection in C++ (redirect cin/cout to file stream, and restore)
- Leetcode之Nim Game
- hdu 5572 An Easy Physics Problem(几何)
- AFNetWorking的实现分析以及简单使用
- 1030. 完美数列(25)
- web前台工作笔记(时间戳、js中clone的使用、js中动态填充数据注意事项、前台查错方法的学习)
- Redirect to ssl in codeigniter
- static的作用
- ORA-12514: TNS:listener does not currently know of service requested in connect
- TFS代码管理器的配置
- Java基础——Java笔记——Java开发工具Eclipse的使用
- hdu 5573 Binary Tree(构造)
- win10 uwp 装机必备应用 含源代码
- 类图
- eclipse使用maven,启动工程tomcat报错:java.lang.ClassNotFoundException: org.springframework.web.context.Contex