CodeIgniter 404 not found on freshly installed apache2

So I start this morning with freshly installed apache2 on my Ubuntu 11, pulling from bitbucket/Mercurial and suddenly it gave me 404 standard apache2 page.

404 not found

Because my CodeIgniter is a standard no index.php and use .htaccess file to activate the mod_rewrite, so this symptom of problem usually caused by non existing mod_rewrite. So I have to activate mod_rewrite first.

sudo a2enmod rewrite

And then restart apache2 to load the mod

sudo /etc/init.d/apache2 force-reload

Checking on `phpinfo()` it will show mod_rewrite is activated, still 404 error because I haven’t modify the `AllowOverride` settings.

So you have to open file in `/etc/apache2/sites-enabled/000-default` by

sudo nano /etc/apache2/sites-enabled/000-default

(you can use vim, gedit or anything :P)

And change the `AllowOverride None’ into `AllowOverride All`. This will allow `.htaccess` to kick in and override apache2 configurations on your CodeIgniter root.

Refresh the page and voila! my controllers are initalized properly.