Remove index.php from Codeigniter using htaccess

In CodeIgniter project the index.php file will be included in your URLs by default. However, we would want to remove index.php from our URL to make it look clean as well as make it SEO friendly.

We can achieve this with following 2 simple steps :

Step 1:

Create .htaccess file in root directory with the following code in it

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Step 2 :

Set  ‘index_page’ config as blank in application/config/config.php

$config['index_page'] = '';

Thats it, now the URL would work without index.php after the base URL.

CHEERSSSS

Follow this video for complete guidance :



Recommended For You

About the Author: Admin