How to remove index.php from url in CodeIgniter

Yes, you can remove the index.php from your url in your CodeIgniter web application.

You just need to add a .htaccess file in your web application folder.

Create a file and give it name .htaccess and save it in the root folder, and then copy the below block of code and paste it in the .htaccess file.


<IfModule mod_rewrite.c>

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?/$1 [L]

</IfModule>

One more change you have to do in your config.php file.

Go to :

application/config/config.php

and remove index.php from $config[‘index_page’]

All Done. Enjoy!