Sunday, May 29, 2011

Remove Index.php CodeIgniter Url On Ubuntu 11.04

1. Preliminary Note
I'm running all the steps in this tutorial with root privileges, so make sure you're logged in as root:
sudo su
2. Enable mod_rewrite module on apache
First enable the module as follows:
a2enmod rewrite
Change all occurrence of "AllowOverRide None" to "AllowOverRide All". Basically all "None" to "All" in the following file:
gedit /etc/apache2/sites-available/default
Restart Apache:
/etc/init.d/apache2 restart
3. Open file config.php on CodeIgniter (application\config\)
Remove index.php on $config['index_page'] = "index.php";
$config['index_page'] = "";
4. Make file .htaccess on CodeIgniter root directory
Fill the file with this code :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Now Index.php on CodeIgniter Url disappear