How to remove index.php from URL using .htaccess file ?
That is this easy :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[^/]*/index\.php [NC]
RewriteRule ^index\.php(.+) $1 [R=301,L]
</IfModule>
Maybe you are using a magento website and you need to keep index.php for the backoffice.
Then add this condition to the .htaccess file
RewriteCond %{REQUEST_URI} !^[^/]*/index\.php/admin.*
and don’t forget to enable rewrite module
a2enmod rewrite