.htaccess Tester
Test how a set of Apache .htaccess RewriteRule/RewriteCond and Redirect/RedirectMatch directives resolve a given test URL — see the exact redirect, internal rewrite, or pass-through it produces, with a directive-by-directive trace.
Input
A path like /article/42, optionally with a query string. Only the path + query are used.
Simulated request
Output
| Property | Value |
|---|---|
| No data yet | |
Directive-by-directive trace
| Line | Directive | Rule | Result |
|---|---|---|---|
| No data yet | |||
Guides
What this tool does
Apache .htaccess files control URL rewriting and redirects through mod_rewrite (RewriteEngine, RewriteCond, RewriteRule) and mod_alias (Redirect, RedirectMatch, RedirectPermanent, RedirectTemp) directives. Getting a rewrite chain right by eyeballing regex is hard — a condition that never matches, a substitution that references the wrong backreference, or a missing [L] flag can silently break the redirect you meant to write.
This tool simulates that resolution: paste your directives, give it a test URL, and it walks the rules directive by directive, showing exactly which RewriteCond matched, which RewriteRule fired, and what the final result is — an external redirect (with status code and Location), an internal rewrite, a 403/410, or a pass-through with no match at all.
How to use it
- Paste your
.htaccessrewrite/redirect directives into the .htaccess Content box. - Enter the URL / path to test — a path like
/article/42, optionally with a query string. - Toggle Simulate an HTTPS request and set the Host header if your rules branch on
%{HTTPS}or%{HTTP_HOST}(common for force-HTTPS and www-canonicalization rules). - Read the Result line for the outcome, and the trace table below it for how each directive evaluated.
Runs automatically as you edit — there's no button to click.
What's simulated
RewriteEngine On|Off,RewriteBaseRewriteCond— regexCondPattern(with!negation and[NC]) and the=literalexact-match form, chained with the same AND/[OR]logic Apache usesRewriteRule— pattern matching (without the leading slash, the usual per-directory.htaccessconvention) plus theNC,L/END,R/R=NNN,F,G,P, andQSAflags, and%{VAR}/%N/$Nbackreference expansionRedirect,RedirectMatch,RedirectPermanent,RedirectTemp(mod_alias)
Directives are read top-to-bottom in a single pass. Apache itself restarts matching from the top of the ruleset after a non-terminal rewrite (no L); this tool doesn't re-loop, so a rule specifically written to catch an already-rewritten URL on a second pass won't re-fire here — most straightforward rewrite chains (redirect-if-http, canonicalize-www, pretty-URL-to-query-string) don't rely on that behavior. File-existence tests (-f, -d, -s) and lexicographic comparisons in RewriteCond always report "not matched" since there's no real filesystem or request to check against, and P (proxy) is reported but never actually fetched.
FAQ
Does this test against my live server? No — everything runs against the text you paste, using the test URL and simulated Host/HTTPS values you provide. Nothing is fetched.
Why didn't my RewriteRule fire?
Check the trace table — it shows every RewriteCond result leading up to the rule, and whether the rule's own pattern matched. A common cause is a leading / in the pattern: .htaccess-context patterns match the path without its leading slash, so ^/article never matches /article/42 — use ^article instead.
What if I just want my .htaccess re-indented, not tested?
Use the .htaccess Formatter. To build common rule blocks (force HTTPS, www canonicalization, hotlink protection, …) from toggles instead of writing them by hand, use the .htaccess Rule Generator.
Privacy
This tool runs entirely in your browser. Your .htaccess content and test URL are never uploaded to a server.
Use it from code
From 3 credits per callREST API
curl -X POST https://api.iotools.cloud/v1/tool/htaccess-tester \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"htaccessRules": "RewriteEngine On\n\n# Force HTTPS\nRewriteCond %{HT…",
"testUrl": "/article/42",
"httpsEnabled": "",
"httpHost": "example.com"
}'Swap in your own key from your account. The tool's fields are the body — no wrapper.
Ask an AI agent
Use the IOTools `htaccess-tester` tool (.htaccess Tester) on this input:
YOUR_INPUT_HEREPaste this at any agent connected to the IOTools MCP server, then add your input.