https://httpd.apache.org/docs/current/howto/htaccess.html
Apache web server allows for decentralized management of configuration via special files placed inside the web tree.
The special files are usually called .htaccess (hypertext access), but any name can be specified in the AccessFileName directive.
A .htaccess file contains one or more configuration directives and is placed in a directory, the directives apply to that directory, and all subdirectories thereof.
The .htaccess files follow the same syntax as the main configuration files.
Since .htaccess files are read on every request, changes made in these files take immediate effect.
To find which directives can be placed in .htaccess files, check the Context of the directive.
The server administrator further controls what directives may be placed in .htaccess files by configuring the AllowOverride directive in the main configuration files.
The use of .htaccess files can be disabled completely by setting the AllowOverride directive to None.
In general, you should only use .htaccess files when you don’t have access to the main server configuration files.
This is typically the case when you contract a web hosting plan with a company.
You should avoid using .htaccess files completely if you have access to apache main server config files.
Using .htaccess files slows down Apache http server. Any directive that you can include in a .htaccess file is better set in a Directory section (main server config files), as it will have the same effect with better performance.
The configuration directives found in a .htaccess file are applied to the directory in which the .htaccess file is found, and to all subdirectories thereof.
However, it is important to also remember that there may have been .htaccess files in directories higher up.
Directives are applied in the order that they are found.
Therefore, a .htaccess file in a particular directory may override directives found in .htaccess files found higher up in the directory tree.