Apache is one of the most popular web servers used by millions of websites. It is highly flexible and easily customizable. However, the .htaccess file is the backbone behind its flexibility.
What is .htaccess?
.htaccess is a simple, hidden text file that allows you to change Apache’s configuration, without actually accessing its config file. Since it is so important, it needs to be hidden, by adding a dot (.) at its beginning. It is commonly used for redirecting pages, rewriting URLs and access control.
One of the most common questions people have is “where is .htaccess file located in Apache”
Where is .htaccess file located in Apache
Before you can even use .htaccess file, you need to enable mod_rewrite. Here’s how to do it:
.htaccess file is typically located at the web root location of apache (/var/www/html or /var/www depending on your Linux distribution). If you want to apply it to only one of your virtual hosts (e.g /var/www/example.com) then you can place it at the root of your website ( /var/www/example.com/.htaccess)