Enable url rewriting like this:
sudo a2enmod rewrite
Then restart Apache:
sudo /etc/init.d/apache2 restart
In the file /etc/apache2/sites-available/default, in the section <Directory /var/www> make sure that ‘AllowOverride All’ appears:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>