Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect site url http to https in codeigniter

I want to redirect my existing site to HTTPS. Currently in browser if URL start with HTTP then it will show bad gateways error but i want to redirect site to HTTPS.

like image 950
kalpak savaliya Avatar asked Jan 23 '16 05:01

kalpak savaliya


2 Answers

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

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule (.*) 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/';
like image 52
Vikash Kumar Avatar answered Oct 04 '22 12:10

Vikash Kumar


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/';
like image 24
Abdulla Nilam Avatar answered Oct 04 '22 13:10

Abdulla Nilam