How to delete index.php from Codeigniter in localhost

If you have installed a codeigniter in XAMPP and want to delete index.php in your URL, this is how I did it.

For example your URL is,

http://127.0.0.1/ci_cms/index.php/admin/users/manage

And you want to make it to,

http://127.0.0.1/ci_cms/admin/users/manage

Firstly, it does not matter if you move application folder out of system folder or keep it under system folder.
You need to modify config.php. $config['index_page'] = “”;
And also add .htaccess to the same level as system folder.
Your .htaccess file should contain the following.

RewriteEngine on
RewriteCond $1 !^(index\.php|images|scripts|css|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

Codeigniter suggests the following code. But if you use it some of your link will go to http://127.0.0/ and shows xampp home page, http://127.0.0/xampp.
If you are installing CI in your root, this code will be fine, otherwise use the first .htaccess for your XAMPP.

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

You can add folder names in images|scripts|css in order to access these folders.
For example I use TinyMCE and I added it under scripts folder which is the same level as system folder.

Also it is good idea to add the following code to a view/header.php.
This enable you to add images like image/myimage.jpg and automatically it becomes http://127.0.0.1/ci_cms/images/myimage.jpg.

That’s it.

3 comments to How to delete index.php from Codeigniter in localhost

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>