The .htaccess file is a configuration file used by the Apache web server to apply specific rules and settings to a directory or website. Common uses of .htaccess include redirecting URLs, setting error pages, and denying or granting access to certain files or directories.
Here are some sample uses and functions of the .htaccess file:
- Performance – Enable gzip compression, set expires headers, leverage browser caching.
- Redirects – Redirect a page or site, create custom 404 pages, etc.
- Domains – Redirect non-www to www urls and vice versa. -Directories – Password protect directories, restrict access.
- Errors – Create custom error pages, set error response codes.
- Media – Disable image hotlinking, restrict video embedding.
- Rewrites – Rewrite URLs, redirect based on conditions, etc.
- Security – Block visitors, disable directory browsing, limit file types, prevent hotlinking.
- Caching – Improve cache handling, set caching policies.
- Encoding – Force a character set across a site.
- Logging – Custom logging and log formats.
- PHP Settings – Alter php settings, enable/disable functions.
- Content Type – Set proper MIME types for files.
- Miscellaneous – Set file upload limits, SSI and CGI configs, etc.
The .htaccess file allows you to configure a site in numerous ways without access to main server config files.
.htaccess File Editor for WordPress Users
All in One SEO (AIOSEO) includes an .htaccess editor, which enables users to edit the .htaccess file easily from within WordPress.
Learn how to use the AIOSEO .htaccess editor.