Remove index.php from CodeIgniter URL Path using .htaccess

If you are using Codeigniter (PHP Framework) you are noticed that by default index.php will be included with your URL.


But you can easily remove index.php from your URL so that your URL should be like :


To do this just follows the following steps:


1. Open config.php from system/application/config directory in your project and replace $config[‘index_page’] = ‘index.php’ by $config[‘index_page’] = ”


2. Create a ‘.htaccess’ file in project root directory, open the file using your favourite text editor, write down the following script and save it.

[sourcecode language=”plain”]
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]


3. In some case the default setting for uri_protocol does not work properly. To solve this problem just replace


$config[‘uri_protocol’] = ‘AUTO’ by $config[‘uri_protocol’] = ‘REQUEST_URI’ from system/application/config/config.php


It works for me. The URL now without the index.php segment.I implemented all of the configuration above on Windows using Xampp.

Hope it will work fine for you also, if not left a comment below the post.

One thought on “Remove index.php from CodeIgniter URL Path using .htaccess”

  1. It’s enormous that you are getting thoughts from this article as well as from our dialogue made at this time.

Comments are closed.