How to Remove index.php from CodeIgniter URL

Hello Readers,

CodeIgniter will add index.php to URL after the base url. For example, if your base url is http://localhost/project, CodeIgniter url will be http://localhost/project/index.php. In order to access a controller the actual path is http://localhost/project/controller but the CodeIgniter path is http://localhost/project/index.php/project.

In order to remove the index.php, we can use .htaccess file. Add the following code to the .htaccess file and save it in the base directory of your project.

RewriteEngine on 
RewriteCond $1 !^(index.php|resources|robots.txt) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L,QSA]


And in your config file, can be found at application/config/config.php, replace

$config['index_page'] = “index.php” by 
$config['index_page'] = “”

In some case the default setting for uri_protocol does not work properly. To solve this problem in from system/application/config/config.php just replace

$config['uri_protocol'] = “AUTO” by 
$config['uri_protocol'] = “REQUEST_URI” 

Thanks for Reading.

Don’t forget to subscribe to Geeks.Gallery, to get free emails to your inbox.

Subscribe to Geeks.Gallery

Follow me


Web Developer at Energy Alternatives India
I'm interested in developing Web applications andkeen on learning new technologies.

View Nagarajan's Profile
Follow me

Latest posts by Nagarajan (see all)

Leave a Reply

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