how to remove index.php in codeigniter

  1. Open the config.php file located in the application/config directory.
  2. Find the $config['index_page'] variable and set its value to an empty string: php $config['index_page'] = '';

  3. Open the .htaccess file in the root directory of your CodeIgniter project. If it doesn't exist, create one.

  4. Add the following code to remove index.php from the URLs: htaccess <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] </IfModule>

  5. Ensure that the mod_rewrite module is enabled in your Apache server. You can do this by uncommenting the following line in the Apache configuration file (httpd.conf): apache LoadModule rewrite_module modules/

  6. In some cases, you might need to set the AllowOverride directive to All for the directory where your CodeIgniter application is located. Locate your virtual host configuration file or add the following within a Directory block: apache <Directory "/path/to/your/codeigniter"> AllowOverride All </Directory>

  7. Restart your Apache server for the changes to take effect.

  8. If you are using NGINX instead of Apache, you can use the following configuration in your NGINX server block: nginx location / { try_files $uri $uri/ /index.php?$query_string; }

  9. Restart your NGINX server for the changes to take effect.

Note: Replace "/path/to/your/codeigniter" with the actual path to your CodeIgniter installation directory.