codeigniter remove index.php

Codeigniter Remove index.php from URL

If we want to make a clean URL in Codeigniter then we need to remove index.php form URL by adding some htaccess rules in our .htaccess file and update some configuration in config.php file. If we look Codeigniter URL without removing index.php file it will looks as below.
Codeigniter remove index.php from URL provides very easy way to extract index.php from our URL’s to make our URL’s more user friendly and SEO friendly as well. Let’s remove index.php form URL.

Codeigniter Remove index.php


Step-1 : Make some changes in config.php file

Make some changes in config.php file Go to “your-project-or-domain/application/config/config.php”
You will find there below code.

Replace above code with below code

Step-2 : Go ahead and add some htaccess rules inside root folder htaccess file

Open your root .htaccess file if there is no file then create a .htaccess file on your root directory and place the below htaccess rewrite rules inside your project htaccess file for codeigniter remove index.php.
Note : If you have your codeigniter project in sub-directory then you need to minor change in .htaccess file rules that will be ” RewriteBase / ” to ” RewriteBase /subdir/ ” . Finally Go ahead and add below rules in your file.

Now look at your website URL you will found clean and user friendly URL without index.php . Now you URL will looks like.
If you face still there is an issue then you need to change one more configuration in config.php file.
You need to find below code

Replace above code with below code

Finally with Codeigniter remove index.php from URL is done.


In this post, I had to go through to solve a headache. CodeIgniter of such a solution in the next version to come out of the box would love to see. If you have any hints or in the context of CodeIgniter URL rewriting information so, share them in the comments.
Feel free to ask questions just leave us a comment and we will get back to you.
Here is some other articles related to Codeigniter
Install and Setup Codeigniter
Codeigniter Write SEO friendly URL’s