How to remove index.php in a codeigniter site to help seo?

by alvera_smith , in category: SEO , 8 months ago

How to remove index.php in a codeigniter site to help seo?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

1 answer


by arlo , 8 months ago


To remove index.php from the URLs in a CodeIgniter site, follow these steps:

Step 1: Enable Apache's mod_rewrite module Make sure the mod_rewrite module is enabled in your Apache server. You can enable it by uncommenting the line "LoadModule rewrite_module modules/" in the httpd.conf file.

Step 2: Configure CodeIgniter's config.php file Open the "config.php" file located in the "application/config" folder of your CodeIgniter installation.

Find the following line:

$config['index_page'] = 'index.php';

Replace it with:

$config['index_page'] = '';

Step 3: Create a .htaccess file Create a new file called ".htaccess" in the root folder of your CodeIgniter installation (the same level as your "application" folder).

Add the following code to the .htaccess file:

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

Step 4: Test your URLs After following the above steps, you should be able to access your CodeIgniter site without the "index.php" in the URLs.

For example: Instead of You can now access it as

This URL structure can be more SEO-friendly as it removes the unnecessary "index.php" segment.