1

i have installed ssl and its working now i need to redirect my http links to https i have update my .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]

and i have added helper

<?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 this helper

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

and i have use force_ssl() function to change http to https

but still its not working, did you see anything wrong or anything else i need to with my codeigniter setup.

i have also change my base user from http to https.

and the most important i am using HMVC, MX_Controller is this having problem?

Pankaj Pawar
  • 305
  • 2
  • 18
  • Possible duplicate of [htaccess redirect to https://www](http://stackoverflow.com/questions/13977851/htaccess-redirect-to-https-www) – Charlotte Dunois Mar 20 '16 at 12:39
  • `.htaccess` file should be sufficient for that action. Add `RewriteEngine on` at the beginning of the file. – Tpojka Mar 20 '16 at 12:45
  • using .htaccess it will redirected me to https but base_url() still taking http:// and not loading my css and js – Pankaj Pawar Mar 20 '16 at 13:33

0 Answers0