AllowOverride directive is used to allow the use of
.htaccess within the web server to allow overriding of the Apache config on a per directory basis.
To allow it for apache on Ubuntu, edit the file /etc/apache2/apache2.conf. An example has been given below:
<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory>
Once you have changed the file as given above, restart the apache server by running the command below:
sudo service apache2 restart