To remove index.php from url you need to create a .htaccess with this code:
<IfModule mod_rewrite.c>Modify /codeigniter with your project path.
RewriteEngine On
RewriteBase /codeigniter
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /codeigniter/index.php
</IfModule>
My project path is /var/www/codeigniter/ so...Put it in your project root directory.
Check if mod_rewrite is enabled. You can create a php file with the next code:
<?php phpinfo(); ?>and in Loaded Modules section check if is loaded mod_rewrite. Or:
if (in_array('mod_rewrite',apache_get_modules())) {If mod_rewrite is not loaded
echo "mod_rewrite loaded";
} else {
echo "mod_rewrite not loaded";
}
sudo a2enmod rewriterestart apache
sudo /etc/init.d/apache2 restartif it doesn't work, you need to enable at least
to your Apache configuration file.AllowOverride FileInfoandOptions FollowSymLink
/etc/apache2/sites-available/default
Ok, now you can say good bye to index.php