.htaccess Tester

Updated October 2026

Paste your RewriteRule, RewriteCond, Redirect and RedirectMatch lines, enter a URL, and see what Apache would do with it: the final redirect or rewrite, every condition evaluated, and loops caught before they hit your server. Free, runs in your browser.

Advertisement

Advertisement

1. Your .htaccess

Supported: RewriteEngine, RewriteBase, RewriteCond, RewriteRule (all common flags), Redirect, RedirectMatch. Other lines are ignored.

2. URL to test

Result

301 redirect

The visitor is sent to https://www.example.com/about?utm=1

Trace, directive by directive

  1. 1: RewriteEngine Onmod_rewrite enabled
  2. 4: RewriteCond %{HTTPS} off [OR]Condition met: "off" matches off [OR]
  3. 5: RewriteCond %{HTTP_HOST} !^www\. [NC]Skipped: an earlier [OR] condition already matched
  4. 6: RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]Condition met: "example.com" matches ^(?:www\.)?(.+)$
  5. 7: RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L]matched, redirects (301) to https://www.example.com/about?utm=1

What This .htaccess Tester Does

Paste the rewrite section of your .htaccess, type a URL, and the tester walks through the file the way Apache's mod_rewrite does in a per-directory context: it matches the RewriteRule pattern first, then evaluates each RewriteCond above it (including [OR] groups and %1 back-references), applies the flags, and, after an internal rewrite, runs the file again with the new URL exactly as Apache does. You get the final outcome (a 301 or 302 to where, an internal rewrite to which file, a 403, a 410, or a loop) and a trace that says for every line whether it matched, why a condition failed, or why it was skipped.

Redirect and RedirectMatch (mod_alias) are simulated too, so you can see which directive wins when both would apply. Nothing is sent anywhere: the whole simulation runs in your browser.

How to Test a RewriteRule or Redirect

  1. Paste your directives in the left box. Comments and unrelated lines (Options, ErrorDocument, WordPress markers) are ignored.
  2. Enter the full request URL, including http:// or https:// and the host. HTTPS and www rules depend on those, not only on the path.
  3. Read the result box: the status code and target for a redirect, or the file Apache would serve for an internal rewrite.
  4. Open the trace to see each line. "Pattern does not match" and "Condition not met" are the two reasons a rule you expected to fire did nothing.
  5. Change a line and the result updates instantly. When it does what you want, copy it back to the server and confirm with the broken link checker, which shows the real first response.

Reading the Trace: Why a Rule Did Not Fire

Trace messageMeaningUsual fix
Pattern does not matchThe regex was tested against the path without its leading slash and failed.Remove a leading / from the pattern (^/old never matches in .htaccess), check anchors and escaped dots.
Condition not metThe pattern matched but a RewriteCond above the rule was false for this request.Check the test string: %{HTTPS} is "on"/"off", %{HTTP_HOST} has no scheme, %{REQUEST_URI} keeps its leading slash.
none of the [OR] conditions matchedA group of conditions joined with [OR] all failed.Make sure the last condition of the group has no [OR] flag, or it swallows the next one.
ignored: RewriteEngine On is missingmod_rewrite is off, so the rule is never evaluated.Add RewriteEngine On above the rules, once.
Pass 2: the URL changedAn internal rewrite happened; Apache re-runs the whole file with the new URL.Normal. Guard script rewrites with !-f / !-d so the second pass stops.
Rewrite loop (500 error)The rules keep producing a URL that matches again.Add a condition that excludes the rewritten URL, or use [END] on Apache 2.4.
Loop riskThe redirect target would be redirected again by the same file.Add a RewriteCond on the host or scheme so the final URL falls through.

Per-Directory Context: Why .htaccess Behaves Differently From httpd.conf

The same rule can work in the main server configuration and fail in .htaccessbecause the two contexts see different input. In .htaccess (per-directory context) Apache strips the directory prefix before matching, so the path has no leading slash; a relative substitution is resolved against the directory (or RewriteBase); and after a rule changes the URL, the rewritten request goes through the whole file again. That second pass is what turns an innocent RewriteRule ^(.*)$ index.php [L] into a loop unless it is guarded:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]
# Pass 1: /about -> index.php. Pass 2: index.php exists (-f), condition fails, done.

The tester reproduces that behaviour, which is why it reports the number of passes. File tests are the one thing it cannot know: it treats a path with an extension (index.php, logo.png) as an existing file and everything else as not existing, and says so in the notes.

Order of Evaluation: Pattern, Then Conditions, Then Flags

A common misconception is that RewriteCond lines are checked first. Apache actually tests the RewriteRule pattern first and only looks at the conditions when the pattern matched. That is why $1 from the rule can be used inside a condition's test string, and why %1 (from the last matching condition) is available in the substitution. The trace shows this order: the rule line appears with "Pattern does not match" without any condition lines when the pattern failed.

Flags the tester understands

R / R=301, L, END, NC, QSA, QSD, NE, F, G, S=n and the [OR] and [NC] condition flags. Unknown flags are reported as errors because Apache answers 500 for them. The RewriteRule generator explains each flag and writes rules you can paste back in here.

Redirect vs. RedirectMatch vs. RewriteRule in the Same File

mod_alias directives (Redirect, RedirectMatch) and mod_rewrite rules are processed by different modules, and mod_alias generally gets to the request first. If both match the same URL you can end up with a redirect chain or a surprising target. The tester evaluates mod_alias lines before the rewrite block for that reason and shows which one answered. Remember that Redirect matches by prefix (Redirect /old /new also sends /old/anything), while RedirectMatch and RewriteRule use regular expressions; the RedirectMatch generator writes anchored patterns that avoid the prefix surprise.

Limits of the Simulation

  • It assumes a .htaccess in the document root with AllowOverride All. Rules in a subdirectory or in a VirtualHost see a different path.
  • File and directory tests are guessed from the extension; %{HTTP_USER_AGENT}, %{HTTP_REFERER} and custom environment variables are empty.
  • Directives it does not know (ErrorDocument, Header, <IfModule> blocks, RewriteMap) are skipped, not executed.
  • Apache's PCRE regex dialect and JavaScript's are nearly identical for the patterns used in redirects; look-behind and possessive quantifiers are the rare exceptions.

For anything beyond that, test on a staging server and read the rewrite log (LogLevel rewrite:trace3 on Apache 2.4).

How to Use

  1. 1

    Paste the rewrite section of your .htaccess into the left box (or load the example)

  2. 2

    Enter the full URL of a request, including http:// or https:// and the host name

  3. 3

    Read the result: a 301/302 to which URL, an internal rewrite to which file, 403, 410, or a loop

  4. 4

    Open the trace to see every RewriteCond and RewriteRule evaluated, with the reason a line matched or was skipped

  5. 5

    Edit a line and the result updates instantly; copy the working version back to your server

Why This Tool Matters for SEO

A wrong .htaccess rule is invisible until it breaks something: a redirect that loops, a rule that never fires because of a leading slash, a condition that fails because %{HTTPS} is "off" behind a proxy, or a syntax error that takes the whole site down with a 500. Testing the file against real URLs before uploading it, and seeing which line did what, turns an afternoon of trial and error into a minute of reading.

Frequently Asked Questions

Does the tester run a real Apache server?

No. It is a simulator that implements mod_rewrite's per-directory behaviour: pattern first, then conditions, flags, back-references, [OR] groups, and the re-run of the file after an internal rewrite. It also handles Redirect and RedirectMatch. The one thing it cannot see is your disk, so -f and -d tests are guessed from the file extension and flagged in the notes.

Why does my rule match in the tester but not on my server?

The usual causes are outside the file: mod_rewrite is not enabled, AllowOverride is set to None so .htaccess is ignored, the file is in a subdirectory (which changes the matched path), another .htaccess higher up or a VirtualHost rule runs first, or the browser cached an earlier 301. Check the server error log and test in a private window.

Why does my rule fire on the server but not in the tester?

Most often the rule depends on something the simulator treats as empty: a custom environment variable, a header such as User-Agent or Referer, a RewriteMap, or a file test on a path without an extension. The trace shows the condition that failed and the notes say what was assumed.

What does "Pass 2" in the trace mean?

In a .htaccess file, after a RewriteRule changes the URL internally, Apache restarts processing of the file with the new URL. The tester does the same and labels each run a pass. A rule that keeps matching its own output never ends, which Apache reports as a 500 error; the tester reports it as a loop.

Does it support RewriteCond [OR] and %1 back-references?

Yes. Conditions are ANDed unless they carry [OR], groups captured in the last matching RewriteCond are available as %1 to %9 in the substitution, and $1 to $9 from the rule pattern can be used inside condition test strings, exactly as in Apache.

Is my .htaccess sent to your server?

No. The parser and the simulator run entirely in your browser. Nothing you paste leaves your device.

Related Tools You Might Like

More in Technical SEO tools · All free SEO tools

Local Processing: Your data never leaves your browser