adding the ssl for https redirection getting ERR_TOO_MANY_REDIRECTS in codeigniter website (admin)

2020-03-26 php .htaccess codeigniter ssl

I am writing of my both htaccess file code here. One is on root path ie. public_html folder that htaccess code is here

<ifModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^admin admin [QSA,L]
RewriteRule ^api admin/api [QSA,L]
RewriteRule ^share  admin/profile [QSA,L]
RewriteRule ^sharefeed admin/feed [QSA,L]    
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index
RewriteRule (.*) index.html [L]
</ifModule>

In public_html folder I have a admin folder. In the admin folder i have full project code in codeigniter php language that's htaccess code is here

Options -Indexes 

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /admin
    # Remove access to system folder
    RewriteCond $1 ^system.*
    RewriteRule ^(.*)$ /index.php/$1 [L]
    # Remove access to system folder
    RewriteCond $1 ^assets/cms/cache.*
    RewriteRule ^(.*)$ /index.php/$1 [L]
    # Allow access to asset directories
    RewriteCond $1 ^application.*
    RewriteCond $1 !(assets.*)
    RewriteRule ^(.*)$ /index.php/$1 [L]
    # Allow access to asset directories
    RewriteCond $1 ^themes.*
    RewriteCond $1 !(assets.*)
    RewriteRule ^(.*)$ /index.php/$1 [L]
    # Check if user is accessing a file or folder that already exists
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /admin/index.php/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php and everything works as normal.
    ErrorDocument 404 /index.php
</IfModule>

Now i am going to add code in this htaccess file for redirection for https

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

that gives error ERR_TOO_MANY_REDIRECTS

Answers

Related