W3docs

How to remove "index.php" in codeigniter's path

To remove "index.php" from the URL in CodeIgniter, you can use the .htaccess file.

To remove "index.php" from the URL in CodeIgniter, you can use the .htaccess file. Here's an example of how to do it:

  1. Create a .htaccess file in the root of your CodeIgniter installation.
  2. Add the following code to the .htaccess file:

Example of removing "index.php" in CodeIgniter path

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
  1. Make sure that the mod_rewrite module is enabled on your server. If not, contact your hosting provider to enable it.

  2. Open the application/config/config.php file and set the $config['index_page'] variable to an empty string:

Example of setting the $config['index_page'] variable to an empty string

// Remove 'index.php' from URLs
$config['index_page'] = '';

Now, the "index.php" should be removed from your URLs and your CodeIgniter application should work as expected.

Note: This process applies to CodeIgniter 3. CodeIgniter 4 uses a different directory structure and routing configuration. This process may vary depending on your hosting provider and server configuration.