添加htaccess和helper之后,基本URL没有采用https

时间:2016-03-20 12:31:32

标签: php .htaccess codeigniter ssl

我已经安装了ssl并且它现在正在工作我需要将我的http链接重定向到https我已经更新了我的.htaccess

### Canonicalize codeigniter URLs

# Enforce SSL https://www. 
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

###
# Removes access to the system folder by users.
# Additionally this will allow you to create a System.php controller,
# previously this would not have been possible.
# 'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]

# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

我添加了助手

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

if (!function_exists('force_ssl'))
{
    function force_ssl()
    {
        $CI =& get_instance();
        $CI->config->config['base_url'] =
                 str_replace('http://', 'https://',
                 $CI->config->config['base_url']);
        if ($_SERVER['SERVER_PORT'] != 443)
        {
            redirect($CI->uri->uri_string());
        }
    }
}

function remove_ssl()
{
    $CI =& get_instance();
    $CI->config->config['base_url'] =
                  str_replace('https://', 'http://',
                  $CI->config->config['base_url']);
    if ($_SERVER['SERVER_PORT'] != 80)
    {
        redirect($CI->uri->uri_string());
    }
}
/* End of file ssl_helper.php */
/* Location: ./application/helpers/ssl_helper.php *////

自动加载此助手

$autoload['helper'] = array('url', 'ssl');

我使用force_ssl()函数将http更改为https

但仍然无法正常工作,您是否在我的codeigniter设置中看到了任何错误或其他任何问题。

我还将我的基本用户从http更改为https。

而且我最重要的是使用HMVC,MX_Controller这有问题吗?

0 个答案:

没有答案