How to enable .htaccess in Apache Webserver

An .htaccess file is a directory-level configuration file,which allows us to override apache webserver configuration without modifying the Apache configuration file. By default, the .htaccess file is not enabled.To Enable it we will follow the following steps.

Step 1

Open the default host configuration file by entering the following command on terminal:

sudo nano /etc/apache2/sites-available/default
Step 2

Look for the section labeled </Directory /var/www>

In that section,Replace the "AllowOverride None" with "AllowOverride All".
<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All  
    Require all granted
Step 3

Finally We need to restart the Apache service.

sudo systemctl apache2 restart