Redirect Http to Https in Codeignitor

Redirect-Http-to-Https-in-Codeignitor
Redirect-Http-to-Https-in-Codeignitor

To Redirect Http to Https in Codeignitor first go to the application/config/config.php file and look for this line:

$config['base_url'] = "";

Set it to your URL with the https e.g. https://example.com

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

Then go to your .htaccess file and add this line in the example given below.
RewriteRule ^(.*)$ https://example.com/$1 [R,L]

<IfModule mod_rewrite.c>
    #Options +FollowSymLinks
    #Options -Indexes
    RewriteEngine on
    # Send request via index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
    RewriteRule ^(.*)$ https://example.com/$1 [R,L]
</IfModule>

More related content visit: https://sahilahlawat.com/category/php/

Leave a Comment