Removing index.php from URL in Codeigniter

Removing index.php from URL in Codeigniter it’s an easy task to do.

Most of the guys don’t wanna see the index.php in the middle of an URL. Here is the way to remove the index.php from URL

Step1

Create a .htacess file in the root folder and paste the below code

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

Step 2 

Go to config.php file in config folder and remove the index.php from $config[‘index_page’] = ‘index.php’;

After that it will look like  $config[‘index_page’] = ”;

All set, please check your url ,

http://example.com/listing/files  It works!

Editorial Staff
 

Editorial Staff at tutsplanet is a dedicated team to write various tutorial articles.