How to remove index.php from URL in CodeIgniter

Hello Guys,

Many of our fellow developers had spend hour’s in searching for the right solution to remove index.php from CodeIgniter (CI) URL’s like we did in our earlier stages of becoming an PHP professional.

Having index.php in your CI project is just like an unnecessary burden being carried out so let’s get rid of it without affecting our precious code.

For accomplishing the task a series of steps needs to be followed. Just follow these 3 simple steps and you’re done.

  • The first step is to go some settings in our config.php file located under config folder. Open the file and set
    • $config[‘index_page’] =’ ‘; 
    • $config[‘uri_protocol’] = ‘AUTO’;
  • The second step is to remove the index.php from your URL parameters located in constants.php file and Base URL (present in config.php file) and everywhere you have defined the URL.
  • The third and last step is to upload a .htacess file on root on the website containing following code.

[cc code]

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

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



Now just run your project and click on the navigation links the index.php disappears without affecting your website.

Download the .htaccess file

That’s all we have for this blog we will be back soon with some more interesting development hacks.


Because Hurdles aren’t really hurdles.


  1. Credo Systemz said:

    great blog.. after reading this blog i got more useful information which really helpful to cracking the php interview..

    April 14, 2017
    • Saurabh Dubey said:

      Thank You Mate

      April 18, 2017

Leave a Reply

Your email address will not be published. Required fields are marked *