sudo nano /etc/apache2/apache2.conf
Scroll down until you find Directory /var/www/>.
Change AllowOverride None to AllowOverride All. Save the file and quit (Ctrl + X and and Y).
sudo a2enmod rewrite
Restart the server
sudo systemctl restart apache2
This is what worked for me and hope it'll work for you too.