How to enable mod_rewrite on Ubuntu

First, you need to add a symlink to the mod-enabled directory

sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/

Then you should open default site configration
sudo gedit /etc/apache2/sites-enabled/000-default

And replace Allow Override None with Allow Override all
Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all

End restart the apache
sudo /etc/init.d/apache2 restart