Redirect https site URL to codeignater

I want to redirect an existing site to HTTPS. Currently in the browser, if the URL starts with HTTP , then the "bad gateways" error will be displayed, but I want to redirect the site to HTTPS .

Thank you for that.

+5
source share
2 answers

Add this to your .htaccess

 RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

Base_url() should be

 $config['base_url'] = 'https://www.example.com/'; 
+4
source

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/'; 
+3
source

Source: https://habr.com/ru/post/1241291/


All Articles