Home >> Latest Articles >> How to remove index php from URL in CodeIgniter

How to remove index php from URL in CodeIgniter

How to remove index php from URL in CodeIgniter: In this artilce will explain you how to remove index.php from URL using .htaccess file in CodeIgniter.

By default, the index.php file will be included in your URLs:

https://www.testexample.com/index.php/news/article/test-article

You can easily remove this file by using a .htaccess file with some simple rules.

You may also like - CodeIgniter Interview Questions
Steps: How to remove index php from URL in CodeIgniter
Step 1:

First of all open config.php file which is located in application/config folder.

Now, find and replace the below code in config.php.

//Find the below code
$config['index_page'] = "index.php"

//Remove index.php
$config['index_page'] = ""
Step 2:

Open .htaccess file.

Add the following code in .htaccess.

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 
You may also like - Node js Interview Questions
Full Stack Tutorials

Author | Blogger @FullStackTutorials | View all articles