Codeigniter 3.1.6 - How to remove index.php from url

Mohammed Sabir picture Mohammed Sabir · Oct 6, 2017 · Viewed 8.1k times · Source

I am working on codeigniter 3.1.6.

I added the .htaccess file. I also changed the base_url path to my project path, removed the index.php from index_page and changed the url_protocol to REQUEST_URI.

Still, while I am redirecting the url to any controllers method it throwing an error as 'The page you requested was not found.'

I also searched and applied different .htaccess but its not working. If I am addling /index.php at end of base_url then its working but its wrong though. It should work without index.php.Only 3.1.6 giving this issue.

note: codeigniter-3.1.4 is working properly only this version is giving an issue

Answer

Yadhu Babu picture Yadhu Babu · Oct 7, 2017

Change folder name CodeIgniter-3.1.6 to ci

Set your base_url to

$config['base_url'] = 'http://localhost/ci/

Use this .htaccess

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