Directory-level configuration file used by Apache web servers. Use this tag if and only if .htaccess content is directly involved in the topic. We know many people are using .htaccess, but kindly ask the members of the community to not use this tag, unless you know it is on-topic in your question. Also notice what the [tag:apache] tag has to say about questions about _configuring_ Apache httpd and their potential off-topicness on Stack Overflow
The .htaccess
(hypertext access) file is a configuration file for the Apache web server, allowing configuration settings to be made at a directory-specific level. It overrides the server-wide or site-level settings in the main Apache server-level configuration but must be enabled in the server-level configuration to work.
Most (though not all) directory-specific 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 has further information about mod_rewrite as well as simpler solutions for many common use cases.
.htaccess
files are also commonly used to define custom error pages (e.g. for 404 errors). They can also be used for specifying directory-specific security and user authentication, configuring the PHP installation, file handlers and MIME types, output compression, and more.
For more information on .htaccess
files and how to use them, see the Apache documentation.
More information
Top Questions for reference
- Tips for debugging .htaccess rewrite rules
- Access-Control-Allow-Origin Multiple Origin Domains?
- How do I manually create a file with a . (dot) prefix in Windows? For example, .htaccess
- How does RewriteBase work in .htaccess
- htaccess redirect to https://www
- How to redirect all HTTP requests to HTTPS using .htaccess rules?
- Hidden features of mod_rewrite
- .htaccess redirect all pages to the homepage on a new domain
- Create subdomains on the fly with .htaccess (PHP)
- .htaccess mod_rewrite - how to exclude directory from rewrite rule
- Leverage browser caching for 3rd party JS
How to ask
- Make sure you explain how .htaccess is involved in your question
- Explain the expected behavior, the actual behavior and the difference between the two
- Show the relevant part of the .htaccess