Redirecting a codeigniter project to https using htaccess: never completes

I want to redirect the Codeigniter 3 website from http to https.

This is my .htaccess file:

 RewriteEngine on RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond $1 !^(index\.php|resources|robots\.txt|static) [NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/?$1 [L,QSA] 

I get this error:

Firefox has detected that the server redirects the request to this address in a way that will never be completed.

+2
redirect php codeigniter .htaccess mod-rewrite
source share
1 answer

Try these .htaccess codes

Method 01

 # force SSL RewriteCond %{HTTP_HOST} \. RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # send request via index.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [L] 

Method 02

 # Enforce SSL https://www. RewriteCond %{HTTPS} !=on RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] ### # Removes access to the system folder by users. # Additionally this will allow you to create a System.php controller, # previously this would not have been possible. # 'system' can be replaced if you have renamed your system folder. RewriteCond %{REQUEST_URI} ^system.* RewriteRule ^(.*)$ /index.php/$1 [L] # Checks to see if the user is attempting to access a valid file, # such as an image or css document, if this isn't true it sends the # request to index.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] 
0
source

All Articles