Remove index.php file from codeigniter

Hello friends…
Hope you are fine.  Today I am going to show a necessary part of codeigniter. It’s how to remove index.php file form codeigniter. You know, when you do any apps with codeigniter, then you will face the following link like- http://localhost/codeigniter/index.php/welcome

Now, I we have to delete index.php part from this and our url should be http://localhost/codeigniter/welcome

Ok, lets start. There are few ways to do this. But, I think, the following system is best. That’s why I am showing this…

First of all open to  system > application > config > config.php
Now, find out $config[‘index_page’] = “index.php”; line and do some modification like below
$config[‘index_page’] = “”; 

Oke, now save your file and run your apps. Hope, it is working….
OK, there is another way to remove index.php file form your directory permanently. This is-

Create a “.htaccess” file in the root of CodeIgniter directory, open the file using your favorite text editor, write down the following script and save it:

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

In some case the default setting for uri_protocol does not work properly. To solve this problem just replace

$config[‘uri_protocol’] = “AUTO” by $config[‘uri_protocol’] = “REQUEST_URI” in the directory of system/application/config/config.php

That’s end for today…
Best of Luck…


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s