CodeIgniter 3 displays index.php in the URL by default. You can remove it by using an .htaccess file to create cleaner, SEO-friendly URLs.

Steps to Remove index.php:

Update the .htaccess File

Create or update the .htaccess file in your CodeIgniter project’s root directory. Add the following code:

Remove index.php from URL in CodeIgniter using .htaccess file.

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

 

Update the config.php File

Edit the application/config/config.php file in your CodeIgniter project and update the index_page configuration:

$config['index_page'] = '';

 


Example

Before Removing index.php:

URL:
http://localhost/infovistar/index.php/Welcome/about_us

After Removing index.php:

URL:
http://localhost/infovistar/Welcome/about_us

 


Testing

Visit your CodeIgniter routes in the browser without the index.php. If it works, you have successfully removed index.php from the URL.

This will ensure clean and user-friendly URLs for your CodeIgniter 3 application!