Redirect site url http to https in codeigniter Redirect site url http to https in codeigniter codeigniter codeigniter

Redirect site url http to https in codeigniter


Add this in your .htaccess

RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Base_url() should be

$config['base_url'] = 'https://www.example.com/';


Try the following code and put these lines into .htaccess file (if not exists then create) at the root of project folder :

RewriteEngine OnRewriteCond %{HTTPS} !=onRewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

And make sure that you have also using https protocol in your $config['base_url'] in config.php file like

$config['base_url'] = 'https://yourproject.local/';