Skip to content
ZeroServer.tools

.htaccess Tester

Test Apache RewriteRule and RewriteCond directives against a URL. See which rule fires first.

Total Rules: 4Matched Rules: 1Final Action: Redirect (301)

Note: %{HTTPS}, %{REQUEST_FILENAME} conditions are simulated (assumes HTTP, non-existent files)

Test Results
Line 9
RewriteRule ^(.*)/$ /$1
301
/old-page
RewriteCond %{REQUEST_FILENAME} !-d
L — last rule, stops processingR=301 — external redirect

How Apache mod_rewrite works

Apache's mod_rewrite processes RewriteRule directives in order. Each rule matches a URL path pattern (regex), optionally preceded by RewriteCond conditions. The [L] flag stops processing after a match.[R=301] issues an external redirect.[NC] makes the pattern case-insensitive. Rules without conditions always apply; with conditions, all conds must match first.

Built and maintained by Meet Shah · Last updated

What this tool is used for

  • Checking whether a rewrite rule matches the path you think it does.
  • Working out which of several rules fires first for a given URL.
  • Testing a rule before deploying it to a live server.
  • Diagnosing a redirect loop by seeing where the chain restarts.
  • Reviewing an inherited rule set nobody documented.

Frequently Asked Questions

How does mod_rewrite decide what to run?
Rules are evaluated top to bottom, and unless a rule ends the processing the rewritten URL is fed back through the whole set again. That loop is why an unguarded rule can rewrite its own output forever, and why `[L]` and a matching condition are not optional refinements.
What do RewriteCond lines do?
They guard the rule immediately after them, and ALL of them must pass unless joined with `[OR]`. They are also the only place to test something other than the path — `%{HTTP_HOST}`, `%{QUERY_STRING}`, `%{REQUEST_FILENAME}` — which is how a rule can skip files that actually exist.
What is the difference between [L] and [R]?
`[L]` stops rule processing internally — the browser sees nothing. `[R]` sends an actual HTTP redirect so the address bar changes, and `[R=301]` makes it permanent. Confusing them is why an internal rewrite sometimes leaks the real path into the URL.
Why does my rule work in .htaccess but not in the main config?
Because the pattern is matched against different strings. In a per-directory context the leading slash is stripped and the directory prefix removed, so `^blog/` in `.htaccess` is `^/blog/` in a `<Directory>` or virtual host block. This catches almost everyone moving rules out of `.htaccess`.
Is a simulation the same as testing on the server?
No. A simulator covers the common directives and cannot reproduce the full interaction with other modules, per-directory context, or the internal re-loop in every detail. Use it to understand a rule's shape, then verify against the real server before relying on it.

Common errors and gotchas

  • Forgetting that the leading slash is stripped in a directory context, which breaks patterns anchored with one.
  • Assuming rules stop at the first match, when processing continues unless a flag says otherwise.
  • Testing a rule in isolation when its behaviour depends on an earlier condition.
  • Overlooking that `AllowOverride` may be off, so none of the rules apply at all.
  • Relying on this rather than the server, whose own module versions decide the real behaviour.

Related Web & SEO tools

Private & free — this tool runs entirely in your browser.

BluehostReliable WordPress & web hosting — exclusive pricing from $3.79/mo.affiliate