.htaccess file is a configuration file for the Apache web server, allowing configuration settings to be made at a directory-specific level, overriding the server-wide or site-level settings in the main Apache config.
Most (though not all) Apache settings can be configured in
.htaccess. One of the most common usages for it is URL redirection using mod_rewrite, which is used by many sites for SEO purposes and to provide easier-to-read URLs. The Apache documentation also has further information about mod_rewrite.
.htaccess files can also be used for specifying custom error pages (e.g. for 404 errors); directory-specific security and user authentication; configuring the PHP installation; file handlers and MIME types; output compression, and more.
The htaccess file is used by the mod_rewrite module of the Apache webserver. It allows URLs to be rewritten for scenarios such as the following
- Shortcuts such as example.com/info to redirect to another page
- Redirects from old pages to new pages
- Password protection of directories and files