For apache version 2.4 and later, you have to go to
/etc/apache2/apache2.conf
You have to edit that file (you should have root permission). Change directory text like this;
<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride All Require all granted
then
sudo service apache2 restart
sudo a2enmod rewrite and then sudo service apache2 restart