A .htaccess file controls how Apache handles requests, but the syntax is dense and easy to misread. If you have inherited a block of rules and you are not sure what they do, you can paste them into the .htaccess Rule Explainer and get a plain-English breakdown of every directive. Here is what the common pieces mean and how to decode a file fast.
What a .htaccess file does
A .htaccess file is a per-directory configuration file for the Apache web server. It can set redirects, rewrite URLs, block access, force HTTPS, and control caching, all without touching the main server config. It is Apache-only, so these rules do nothing on Nginx. WordPress sites on Apache rely on it for pretty permalinks.
The core rewrite directives
Most of the confusing lines belong to the rewrite engine. Here is what each one means:
- RewriteEngine On turns URL rewriting on. Nothing below it runs without this.
- RewriteRule matches a request against a pattern and rewrites or redirects it to a new target.
- RewriteCond sets a condition that must be true before the RewriteRule below it fires. Use it to check the host, the requested file, or query strings.
Read them top to bottom. A RewriteCond only applies to the very next RewriteRule, which trips up a lot of people.
Flags in square brackets
The bracketed flags at the end of a rule change its behavior:
- [L] means last, so stop processing further rules if this one matches.
- [R=301] means redirect with a 301 permanent status. A 302 is temporary.
- [NC] means no case, so the match ignores upper and lowercase.
These often combine, like [R=301,L] for a permanent redirect that stops further rewriting. Getting the flag wrong is a common cause of redirect loops.
The WordPress default block
Almost every WordPress site has a standard block wrapped in # BEGIN WordPress and # END WordPress. It routes any request that is not a real file or folder through index.php, which is how permalinks work. If you see it, leave it alone unless you know why you are changing it.
Explain any rule in two steps
- Open the .htaccess Rule Explainer and paste your rules.
- Read the line-by-line explanation of each directive, condition, and flag.
It analyzes the text you paste and nothing else. There is no fetch, no upload, and no server call, so your config stays in your browser.
Related tools
- Need to build rules instead of read them? Use the .htaccess Builder.
- Speeding up a site? Try the .htaccess Gzip Compression Generator.
- Want browser caching headers? See the .htaccess Browser Caching Generator.
Stop guessing what a cryptic rule does. Paste it, read the plain English, and edit with confidence.