What
The .htaccess (short for 'hypertext access') file is a distributed server configuration file. This means that it configures the server only in the directory the .htaccess file is in.
It is used on the Apache web server. It can also be used on a handful of other web servers like LiteSpeed.
Why
The . htaccess file allows you to make changes to your website's configuration without having to edit server configuration files.
How
The .htaccess file is placed in a directory on the web server. When this is done it will be executed by the Apache web server when a request is made from that directory. It is common to place a .htaccess file in a site's root directory e.g. /public_html. This configures the web server for the entire website. It is a little less common to place .htaccess files in a sub-directory, but it is practiced and has some specific uses.
CAUTION - It is important to know that the .htaccess file, like any other Apache configuration file, is read from top to bottom. This means that configurations at the top will be executed before the ones at the bottom. You will need to pay attention to the order of your rules to ensure it is working correctly and efficiently.