Home » Php » .htaccess – I am unable to remove index.php from URl in codeigniter 3.1.11

.htaccess – I am unable to remove index.php from URl in codeigniter 3.1.11

Posted by: admin February 25, 2020 Leave a comment

Questions:

I tried adding .htaccess in root folder from the documentation available. i searched all over the internet but nothing solved my problem.

code inside .htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

made a changes in apache file httpd

LoadModule rewrite_module modules/mod_rewrite.so

can anyone tell me what could be the reason?

How to&Answers:
Find the below code
 $config['index_page'] = "index.php"
Remove index.php
$config['index_page'] = ""

Write below code in .htaccess file

<IfModule mod_rewrite.c>
 RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

Answer:

some cases the default setting for uri_protocol does not work properly. To solve this 
issue just open the file config.php located in application/config and then find and 
replace the code as:

  Find the below code

 $config['uri_protocol'] = "AUTO"

  Replace it as

 $config['uri_protocol'] = "REQUEST_URI"