Try the following code and put these lines in the .htaccess file (if it does not exist, then create it) in the root of the project folder:
RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
And make sure you also use the https protocol in $ config ['base_url'] in the config.php file, for example
$config['base_url'] = 'https://yourproject.local/';
source share