What .htaccess is #
The .htaccess file is a configuration file that Apache web servers read on every request. It sits in your WordPress site’s root directory and contains instructions that tell the server how to handle requests before WordPress itself runs. Apache applies these instructions instantly, without any plugin activation or WordPress involvement.
The file is named .htaccess with a dot at the start and no file extension. Most FTP clients and file managers hide dot files by default. You need to enable “show hidden files” to see it. It only exists on Apache-based servers. Sites running on Nginx use a different configuration system and don’t have an .htaccess file.
What WordPress uses it for #
The primary job WordPress gives .htaccess is enabling pretty permalinks. When you activate a permalink structure in Settings > Permalinks, WordPress writes a block of rewrite rules to your .htaccess file. These rules intercept requests for URLs like /your-post-name/ and tell Apache to route them through WordPress’s index.php, which then looks up what that URL should show. Without these rules, your permalink structure would produce 404 errors on every page except the homepage.
This is why saving permalinks (even without changing the setting) regenerates the .htaccess and fixes broken links: WordPress rewrites the rewrite rules from scratch, replacing any corrupted or missing ones.
What else ends up in .htaccess #
Many plugins and security tools add their own rules to .htaccess. Caching plugins add cache control headers. Security plugins add rules to block specific IPs, block access to sensitive files, or enforce HTTPS. If multiple plugins are writing to .htaccess at the same time or write conflicting rules, the file can accumulate rules that conflict with each other or with WordPress’s own rewrite block.
Why a corrupted .htaccess causes 500 errors and 404s #
Apache processes .htaccess rules in order from top to bottom. A syntax error anywhere in the file stops Apache from processing the rest. A missing rule that WordPress depends on produces 404 errors on all pages except the homepage. This is why renaming .htaccess to .htaccess_old (effectively disabling it) and then saving permalinks to regenerate a fresh one is a common and effective fix for both 500 errors and broken permalinks. See 500 Internal Server Error and Broken Permalinks and 404 Errors for those specific repair steps.
