WordPress permalinks not working

I just got an issue where the permalinks on a WordPress didn’t work even though I had an .htaccess file and I had selected “Post name” in the permalinks option page in WordPress.

The problem was to do with mod_rewrite not being enabled on my server. So I had to do “sudo a2enmod rewrite” and then restart Apache and the problem got fixed.