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

Member

by jerad , in category: PHP General , a month ago

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

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by giovanny.lueilwitz , a month ago

@jerad 

To remove "index.php" from the URLs of a CodeIgniter site for SEO purposes, you can follow these steps:

  1. Open the CodeIgniter configuration file located at application/config/config.php.
  2. Look for the line that says $config['index_page'] = 'index.php'; and change it to $config['index_page'] = '';
  3. Next, you need to create a .htaccess file in the root directory of your CodeIgniter site. If there is already an .htaccess file, make sure to backup it before making any changes.
  4. Add the following code to the .htaccess file:
1
2
3
4
5
6
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>


  1. Save the .htaccess file and test your website to see if the "index.php" has been removed from the URLs.


By following these steps, you should be able to remove "index.php" from the URLs of your CodeIgniter site, which can help with SEO by creating cleaner and more user-friendly URLs.