.htaccess is a Apache configuration file which is used on running Apache web server software. If we create .htaccess file in web root directory then this file is detected and executed by the Apache web server. It is used to alter the Apache configuration. It is used to enable/disable additional functionality and features. This facilities include basic redirect functionality, for example if a 404 found on the site. This is also used to secure content using password protected or image hot linking prevention.
.htaccess also allow users to override the Apache global and virtual host setting.
Enable .htaccess In Apache
You can edit Apache configuration file or Virtual host configuration file in your favourite editor and add the below directory tag.
In the first directory tag I have disabled using of .htaccess in /var/www/html directory. And in second
directory tag I have enabled the uses of .htaccess for /var/www/vhost directory.
# Disable .htaccess for /var/www/html directory for security <Directory "/var/www/html"> Allowoverride none # Enable .htaccess for /var/www/vhost directory and its subdirectories <Directory "/var/www/vhost/"> Allowoverride all