Apache2 does not have mod_rewrite turned on by default. Fortunately there are just a few steps to get this functionality working.
First activate rewrite engine using the following command.
Then allow override in the site configuration file on Apache. In my case I am testing it on a development machine, so I will edit the main file
sudo gedit /etc/apache2/sites-enabled/default.
by changing AllowOverride from None to All.
Options Indexes FollowSymLinks MultiViews
allow from all
At the end Restart apache2.
sudo /etc/init.d/apache2 restart