How to Enable .htaccess in Apache Web Server

Through .htaccess, we can enable the directory level configuration for Apache web server. This will help users to override the Apache global and virtual host settings.

Enable .htaccess in Apache

To Enable .htaccess in Apache Edit Apache virtual host configuration file in your favorite editor and add the following Directory tag. The first directory tag will disable using of .htaccess in /var/www directory. The second directory tag will enable the uses of .htaccess under /var/www/html directory.

Update /var/www/html with your application document root.

# Disable .htaccess for /var/www directory for security
<Directory "/var/www">
Allowoverride none

# Enable .htaccess for /var/www/html directory and its subdirectories
<Directory "/var/www/html">
Allowoverride all

That’s all we have to do.