codeigniter without index.php not working

CodeIgniter: Removing index.php from URL

To remove "index.php" from the URL in CodeIgniter, follow these steps:

Step 1: Enable "mod_rewrite"

Ensure that the "mod_rewrite" module is enabled in your Apache server configuration.

Step 2: Create or Modify .htaccess File

Create a file named ".htaccess" in the root directory of your CodeIgniter installation or modify the existing one if it already exists. Add the following code to the .htaccess file:

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

Step 3: Update Config.php

Open the "config.php" file located in the "application/config" directory of your CodeIgniter installation. Find the following line:

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

And change it to:

$config['index_page'] = '';

Step 4: Adjust Base URL

In the same "config.php" file, ensure that the base URL is correctly set. Find the following line:

$config['base_url'] = 'http://www.yourdomain.com/';

And replace it with your actual base URL:

$config['base_url'] = 'http://www.yourdomain.com/';

Step 5: Test Your Configuration

After completing the above steps, try accessing your CodeIgniter application without "index.php" in the URL and ensure that it works as expected.