kalpak savaliya
kalpak savaliya

Reputation: 88

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.

Upvotes: 5

Views: 3065

Answers (2)

Abdulla Nilam
Abdulla Nilam

Reputation: 38609

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/';

Upvotes: 3

Vikash Kumar
Vikash Kumar

Reputation: 1111

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/';

Upvotes: 3

Related Questions