How to use the .htaccess Tester & Validator
- Paste your
.htaccessfile (or click Test rules in the .htaccess generator). - Check the validation panel for errors that would cause a 500 error, and warnings for rules that never match.
- Enter a request URL to simulate it: each condition and rule is evaluated and the final redirect or rewrite is shown.
- List existing files and directories to test
-fand-dconditions.
What the validator checks
- Unknown directives and typos — Apache answers any unknown directive in .htaccess with a 500 Internal Server Error.
- Server-only directives such as
ServerName,<VirtualHost>or<Directory>, which are not allowed in .htaccess. - Unbalanced containers — an
<IfModule>or<FilesMatch>that is never closed. - Invalid regular expressions and unknown
RewriteRule/RewriteCondflags. - Logic problems: patterns starting with
^/(they never match in .htaccess), redirects withoutL, conditions with no rule, rules beforeRewriteEngine On. - Compatibility: Apache 2.2
Order/Allow/Deny,php_valueon PHP-FPM hosts, mixedOptionssyntax.
How the rewrite simulation works
Like Apache, the tester strips the leading slash from the path, evaluates each RewriteRule in order, checks its RewriteCond lines (with [OR] and [NC]), substitutes $1 and %1 back-references and server variables such as %{HTTP_HOST}, %{HTTPS}, %{REQUEST_URI} and %{QUERY_STRING}, and applies flags like R=301, L, QSA, F and G. After an internal rewrite it runs the rules again, just as Apache does in per-directory context. Redirect and RedirectMatch are tested too.
Limits
The simulator uses JavaScript regular expressions, which match PCRE for almost all .htaccess patterns. It cannot know your server’s file system (list files for -f/-d tests), RewriteMap, environment set by other modules, or the order in which mod_alias and mod_rewrite run on your server. Always confirm with a real request — the redirect checker shows the live redirect chain.
Build a new file with the .htaccess generator, and test the regular expressions in detail with the regex tester.
Tools that pair well with the .htaccess Tester & Validator
- Htpasswd Generator — Generate user:hash lines for HTTP Basic Authentication in Apache, Nginx, Traefik and Caddy — with bcrypt by default and nothing sent to a server.
- HTTP Status Codes — Every standard HTTP response code explained in plain English, with when to use it and how it affects SEO.
- .gitignore Generator — Tick your stack — Node, Python, React, Next.js, Docker, macOS, VS Code and 40 more — and get one clean, de-duplicated .gitignore with commented sections, ready to download.
- Git Command Generator — Pick a task like “undo the last commit but keep my changes” or “rename a branch on GitHub”, fill in your branch names and get the exact Git commands — each line explained, risky steps flagged.
Frequently asked questions
How do I find the line causing a 500 error?
Why does my RewriteRule ^/page$ never match?
^page$ instead of ^/page$.