An .htaccess file (hypertext access)) is a directory-level configuration file supported by various web servers, which is used for site access settings such as URL redirection, URL shortening, security access control (by different web pages and files), and more. A site can have more than one .htaccess file and these are placed inside the web tree, that is, inside the directories and their subdirectories.
What is .htaccess for?
.htaccess files act as a subset of the server’s global configuration file (such as httpd.conf) for the directory in which they are located or all subdirectories. The original purpose of .htaccess, reflected in its name, was to allow access control by directory, for example, asking for a password to access the content to prevent third parties from trying to modify our files.
More commonly, however, .htaccess files define or suppress many other configuration options, such as content type, character set, CGI manipulators, and so on.