Removing index.php from the URL in CodeIgniter

To remove it you must do few things (using Apache2 and Ubuntu):

1. sudo su – admin rights

2. Enable mod_rewrite of the apache:
         a2enmod rewrite

3. Change all appearances of “AllowOverRide None” to “AllowOverRide All” in the file:

gedit /etc/apache2/sites-available/default

Restart Apache:

/etc/init.d/apache2 restart

3. Open config.php of CodeIgniter (applicationconfig)
Remove index.php on $config[‘index_page’] = “index.php”;

$config[‘index_page’] = “”;

4. Create .htaccess in CodeIgniter main directory with :

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

Greetings!

You may also like...