Removing index.php Codeigniter Apache

First don't forget to set apache mod_rewrite

sudo a2enmod rewrite

create .htaccess in the root of the application

RewriteEngine on
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

then update application/config/config.php and change the :

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

don't forget to change your RewriteBase if needed from:

RewriteBase /
to
RewriteBase /codeigniter/

Incase it doesn't work... sometimes every server's setting are different

$config['uri_protocol'] = 'AUTO';
or
$config['uri_protocol'] = 'PATH_INFO';
or
$config['uri_protocol'] = 'REQUEST_URI';

if doesn't still work, replace AllowOverride None by AllowOverride All

sudo nano /etc/apache2/sites-available/default

Don't forget to restart apache

sudo /etc/init.d/apache2 restart

Subscribe to You Live What You Learn

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
[email protected]
Subscribe