Home >>Codeigniter Tutorial >How to Remove index.php in Codeigniter

How to Remove index.php in Codeigniter

 In CodeIgniter URLs are designed to be search engine and human friendly By default.

In Codeigniter by default index.php is included in the URLs. But We can easily remove the index.php from Codeigniter URLs using .htacss file.

Default Codegniter URLs look like this

https://phptpoint.com/index.php/tutoria/

Why we should remove index.php from Codeginiter URLs ?

All we know Codeigniter URLs are designed Search Engine Friendly as well as User Friendly By default. So we also want to maintain the standard of URLs, thats why we always remove index.php from Codeigniter URLs.

To remove index.php from URLs we have to follow Some Steps.

Step 1 First we need to update our config.php file(Line no 38).

Open application/config/config.php file.

//old Code 
$config['index_page'] = "index.php”
//New updated code(Onlye Need to remove index.php )
$config['index_page'] = ""

Step 2 We need to create .htaccess file and save inside Codeigniters Root 

Add these few lines inside .htaccess


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

Output



No Sidebar ads