Enabling mod rewrite on Apache 2.4 can sometimes become tricky. If your Apache version is 2.4, you may have to go to
/etc/apache2/. There will be a file named
apache2.conf. You have to edit that one(you need sudo permission). Edit the text in there to resemble the one below.
Options Indexes FollowSymLinks
Require all granted
Now restart apache by typing :
sudo systemctl reload apache2
Now check if your mod rewrite works as expected.