Codeigniter Remove index.php

Introduction:

Well the first thing that you realize when you install Codeigniter is that the URLs are really huge, not SEO friendly and not user friendly. While working with Codeigniter (CI Version 3.0+) one common problem is always face by every developer that its “index.php” gets append to every URL and no one wants to be appear it. The first thing that you usually do for your Codeigniter project is to remove the index.php file from the URL to make it working for parent as well as sub folders do follow below steps.

Steps to remove index.php:

Step1: Open the file config.php that is located in directory application/config path.  Find the below code in this file. Line number is near to 38 if you not made any change in this file yet.

$config[‘index_page’] = ‘index.php’;

Now, replace above code by line given below

$config[‘index_page’] = ”;

 

Step2: Go to the parent folder of Codeigniter where find for .htaccess file. If this file does not exist the do create it.

Step3: Write below code in this .htaccess file

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

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

</IfModule>

That’s it. Now open your Codeigniter project in browser and check its working.

 

Need to develop a website for your business? Solace Infotech is there to help you with their Codeigniter experts. Contact us to develop an effective website using codeigniter framework that will reach your business to the success that you deserves.

Good Luck! Keep reading our Blogs.