Remove index.php from CodeIgniter URL Path using .htaccess

Nov 15, 2013, by admin

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 : http://yourdomainname.com/controller/action/var1/var2

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.
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 be helpful for you all to get more updates like the page Bugtreat Technologies