Remove index.php from URL in CodeIgniter

CodeIgniter is basically MVC framework in which all controller logic called through index.php file.

It’s look odd in url. To remove index.php, following are simple steps:

1) Create a .htaccess file :

.htaccess file used for server level routing in website.

Example: If you hit, it will work like following url: sometestexample/index.php

To remove index.php, put the following code in .htaccess file

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

Now you need to change in configuration

$config['index_page'] = "index.php";


$config['index_page'] = "";

Now you need to restart the server to reflect new changes. That’s all!

Leave a Reply