Skip to main content

.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

Result
PropertyValue
No data yet

Directive-by-directive trace

Result
LineDirectiveRuleResult
No data yet
Was this helpful?

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

  1. Paste your .htaccess rewrite/redirect directives into the .htaccess Content box.
  2. Enter the URL / path to test — a path like /article/42, optionally with a query string.
  3. 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).
  4. 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, RewriteBase
  • RewriteCond — regex CondPattern (with ! negation and [NC]) and the =literal exact-match form, chained with the same AND/[OR] logic Apache uses
  • RewriteRule — pattern matching (without the leading slash, the usual per-directory .htaccess convention) plus the NC, L/END, R/R=NNN, F, G, P, and QSA flags, and %{VAR} / %N / $N backreference expansion
  • Redirect, 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.

htaccessapachemod_rewriterewrite ruleredirecturl rewriteweb serverseo

Use it from code

From 3 credits per call

REST 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_HERE

Paste this at any agent connected to the IOTools MCP server, then add your input.

Love the tools? Lose the ads.

One payment clears every ad from your account, for good. No subscription, no tracking.