Codeigniter is rapid development php web framework used to develop fully featured dynamic websites. It is loosely based on MVC (Model, View, Controller) Pattern and  famous for it speed in comparison of other PHP Frameworks. Here we will discuss about the topic “How to remove index.php file from url in codeigniter ?”.

Why we want to remove index.php from Codeigniter ?

Actully the URLs of codeigniter are design search engine friendly and maintain standards and make url clean, we remove the index.php.

How to remove index.php from Codeigniter ?

Here i will remove the index.php file using .htaccess file by defining its rules. htaccess is a configuration file that is used by apache web server.  htaccess file is placed into a folder and when server access this directory, server load .htaccess file first then other files. it is use to alter the configuration of of apache web server to on/off additional functionality. it provides some functionality like redirection, password protection, image hot link prevention, prevent user by ip etc.To remove URLs using htaccess REWRITE_MODE of apache server should be on.

Now we return back to topic “How to remove index.php ??“.

URL Before removing

Url before remove index.php



URL After removing

Url after remove index.php



I am mentioning some steps as given below.

1:  Create a .htaccess file into root directory of your codeigniter project

Codeigniter Direcotry structure


2:  Write code into .htaccess file as given below


3:  Go to application/config and open config.php file and find below line.

and replace with below code

4: Default settings for uri_protocol is not working sometimes, to solve this issue find the following line in config.php


and replace as below code

You can also read Google place autocomplete address form api

Now your index.php has removed successfully and your url seems like as follow.

Hope guys it will help you to remove index.php from codeigniter and Keep reading our blog.