Please add your below code in your route .htaccess file
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule (.*) http://example.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
Additionally, check your $config['base_url'] and add your base url:
$config['base_url'] = http://localhost/project/
Then it will work like as charm and you will redirect to another controller without the index.php
Example: http://localhost/project/home
Use of index function:
www.example.com/welcome/index
If you need to use index function in URL, For that Please set route in routes file.
Please check it with as above