How to remove index.php from url in CodeIgniter


Yes, you can remove the index.php from your url in your CodeIgniter web application.

You just need to add a .htaccess file in your web application folder.

Create a file and give it name .htaccess and save it in the root folder, and then copy the below block of code and paste it in the .htaccess file.


<IfModule mod_rewrite.c>

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?/$1 [L]

</IfModule>

One more change you have to do in your config.php file.

Go to :

application/config/config.php

and remove index.php from $config[‘index_page’]

All Done. Enjoy!

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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