1. First open the apache config file
sudo gedit /etc/apache2/apache2.conf
2. Change AllowOverride from value ‘none’ to ‘All’ as given below
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
3. Activate mod_rewrite
sudo a2enmod rewrite
4. Restart the apache server to put this changes to effect.
sudo service apache2 restart