previously due to incorrect .htaccess logic, many of my http://example.com/path/ url is redirected to https://example.com/index.php?/path/
so there are many pages crawled by Google with https://example.com/index.php?/path/
I am using codeigniter, I do not want index.php in my URL, so I have rewrite rules that remove the index.php from the URL, so below is the rewrite rule for that.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
But since there are many pages already crawled by Google with index.php in the URL, I want to redirect those URL to WITHOUT index.php but this will create conflict and create infinite redirect, one remove then one add, on and on.
RewriteCond %{REQUEST_URI} ^/index\.php$
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)index\.php https://example.com%1? [R=302,L]
so when I access example.com/path/ this causes "Too many redirect" issues.
I am stuck with my logic here.
what should I do ?