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.
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/';
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/';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With