What are .htaccess files?
.htaccess files (or "distributed configuration files") provide a way to make configuration changes on a per-directory basis. A file, containing one or more configuration directives, is placed in a particular document directory, and the directives apply to that directory, and all subdirectories thereof.1
Using .htaccess files will allow you to control several aspects of your web directories, including authentication, security, error pages, access control lists and many others.
Apache documentation recommends that utilizing the main server configuration file is preferable to using .htaccess. But, as many webmasters do not have permission to edit the main server configuration file, .htaccess files can be used as an alternative.2