CodeIgniter removing index.php from url

To remove index.php from URL using .htaccess file in CodeIgniter. htaccess is the shortened used for Hypertext Access, which is a powerful configuration file that controls the directory “.htaccess”.  CodeIgniter’s URLs are designed to be search engine friendly and to human too. and so to maintain the standards we need to remove the default index.php which appears in the url of codeigniter applications, so that the url becomes search engine friendly and looks clean.

By default, the index.php file will be included in your URLs:

example.com/index.php/news/article/my_article

If your Apache server has mod_rewrite enabled, you can easily remove this file by using a .htaccess file with some simple rules.

Step 1:- config.php

Open config.php and do following replaces

to

Step 2:- config.php

In some cases the default setting for uri_protocol does not work properly. Just replace

by

Step 3:- .htaccess

Note: .htaccess code vary depending on hosting server. In some hosting server (e.g.: Godaddy) need to use an extra ? in the last line of above code. The following line will be replaced with last line in applicable case: