Free .htaccess Rule Tester

Test .htaccess RewriteRules and redirects. Step-by-step rule evaluation for any URL. Free, fast, and works entirely in your browser with no sign-up required.

Updated

Share:
Home/Website Tools/.htaccess Rule Tester

.htaccess Rule Tester

Test .htaccess RewriteRules and redirects. Step-by-step rule evaluation for any URL path.

Common .htaccess Snippets

Enter a URL path (e.g. /old-page) or full URL.

Simulation Limitations

This tool simulates .htaccess processing in the browser. Server variables like %{REQUEST_FILENAME} are approximated (file/directory tests always return false). For production use, test directly on your server.

Frequently Asked Questions

What is the .htaccess Rule Tester?

The .htaccess Rule Tester is a free online tool that test .htaccess rewriterules and redirects. step-by-step rule evaluation for any url. It runs entirely in your browser with no installation or sign-up needed.

What directives can I test?

RewriteRule, RewriteCond, Redirect, RedirectMatch, and Header directives.

Does it show why a rule matched?

Yes — step-by-step evaluation shows which conditions were met or skipped.

Is it free?

Yes, completely free.

Is my data safe with this tool?

Absolutely. The .htaccess Rule Tester processes everything client-side in your browser. No data is uploaded to or stored on any server. Your content remains private on your device at all times.

Does the .htaccess Rule Tester work on mobile devices?

Yes, the .htaccess Rule Tester is fully responsive and works on smartphones and tablets. You can use it on any device with a modern web browser -- no app download required.

Do I need to create an account to use this tool?

No account or registration is needed. Simply open the .htaccess Rule Tester in your browser and start using it immediately. There are no sign-up walls or usage restrictions.

How do I use the .htaccess Rule Tester?

Simply enter your input in the provided field, adjust any settings to your preference, and the tool will process it instantly. You can then copy the result to your clipboard or download it.

Which browsers are supported?

The .htaccess Rule Tester works in all modern browsers including Chrome, Firefox, Safari, Edge, and Opera. For the best experience, use the latest version of your preferred browser.

What is the difference between a 301 and a 302 redirect in .htaccess?

In an .htaccess RewriteRule, the flag [R=301] issues a permanent redirect and [R=302] issues a temporary one — and the choice matters for SEO. A 301 tells search engines the move is permanent, so they transfer ranking signals from the old URL to the new one and update their index. A 302 signals the original URL will return, so engines keep indexing the old address and may not pass authority along. The common mistake is leaving the default, since a bare [R] flag resolves to 302. Use 301 for renamed pages, www or HTTPS canonicalization, and retired URLs; reserve 302 for genuinely short-lived moves like maintenance pages. Paste your rules above with a test URL and the tester reports the exact HTTP status each redirect would return, so you can confirm it says 301 before you ship it.

What does the [L] flag do in a RewriteRule and why does rule order matter?

The [L] flag means "last": when a RewriteRule with [L] matches, Apache stops processing the remaining rewrite rules in that round and uses the result. Because Apache evaluates rules top to bottom in sequence, the order of your rules changes the outcome as much as the rules themselves. A broad rule placed early can match and halt before a more specific rule below ever runs, or a missing [L] can let several rules fire in a chain and produce a URL you never intended. This is one of the hardest things to reason about by reading raw text. The tester walks your rules in the same top-to-bottom order Apache uses and marks exactly where [L] stops processing, so you can see whether a rule is short-circuiting the ones beneath it before going live.

Why does my RewriteRule not match the URL I expect?

The most common reason is the leading slash. In a per-directory .htaccess file, the path Apache hands to your RewriteRule pattern has the leading slash already stripped, so a pattern like ^/old-page will never match — you want ^old-page instead. Other frequent culprits are an unescaped dot (use \. for a literal period), a greedy pattern such as (.*) catching more than intended, a RewriteCond above the rule that quietly fails so the rule is skipped, or RewriteEngine never being switched On. Regex anchors matter too: ^ and $ pin the start and end of the path. The step-by-step trace here shows the value being compared against your pattern and a plain-English note saying whether it matched or was skipped and why, which usually pinpoints the mismatch in seconds. Paste the rule and a sample path to check it.

What causes an .htaccess redirect loop and how do I find it?

A redirect loop happens when a rule keeps rewriting a URL to a target that matches the same rule again, so the browser bounces endlessly and shows an ERR_TOO_MANY_REDIRECTS error. Typical causes are an HTTPS-forcing rule whose condition never becomes satisfied behind a proxy, a www rule that re-triggers on its own output, or two rules that point at each other. The fix is usually a tighter RewriteCond that excludes the already-correct state — for example only redirecting when %{HTTPS} is off — plus a proper [L] flag to stop further processing. Reading rules statically rarely reveals a loop. Run your snippet against a test URL in the tester and watch the trace: if the output URL would re-enter the same matching rule, the step-by-step evaluation makes that chain visible so you can break it before deploying.

Can this tester check RewriteCond rules that test whether a file exists, like -f and -d?

Not reliably, and that is by design. Conditions such as RewriteCond %{REQUEST_FILENAME} !-f or -d ask Apache whether a real file or directory exists on disk, and a browser has no access to your server's filesystem. So the tester approximates them: file and directory existence tests resolve to false, and %{REQUEST_FILENAME} is stood in with the request path rather than a true filesystem path. That means logic depending on -f, -d, or -e — common in front-controller setups that route missing files to index.php — will not behave exactly as it does on Apache. The tool is built to validate the logic, ordering, and flags of your rewrite and redirect rules quickly and privately. Use it to confirm patterns, capture groups, status codes, and [L] behaviour here, then verify anything filesystem-dependent on your actual server before going live.

Embed This Tool

Add a free, live version of this widget to your own website or blog post — it runs entirely in your visitors' browsers, with a credit link back to The Toolbox.

Copy & paste this HTML
<iframe src="https://getthetoolbox.com/embed/htaccess-tester" title="Free .htaccess Rule Tester — The Toolbox" width="100%" height="380" style="max-width:480px;border:1px solid #e2e8f0;border-radius:12px" loading="lazy"></iframe>
<p style="font-size:12px;margin:4px 0 0"><a href="https://getthetoolbox.com/website-tools/htaccess-tester?utm_source=embed&utm_medium=widget" target="_blank" rel="noopener">Free .htaccess Rule Tester</a> by The Toolbox</p>

About the .htaccess Rule Tester

The .htaccess Rule Tester lets you paste an Apache .htaccess snippet, enter a test URL, and watch exactly how your rewrite and redirect rules would fire — line by line, before you ever touch a live server. Instead of editing rules on production and refreshing the page hoping nothing broke, you see the outcome instantly: the final URL, the HTTP status code, and which rule was responsible.

It is built for developers, SEO specialists, and site owners who manage Apache or shared hosting. If you have ever stared at a RewriteRule wondering why a redirect loops, why a page 404s, or why [L] did not stop processing where you expected, this tool turns that guesswork into a readable trace. Everything runs in your browser — no sign-up, no upload, and no files leave your device.

What the tester evaluates

The tester reads common Apache directives and walks them top to bottom, the same order Apache does:

  • RewriteEngine — tracks whether rewriting is on; rules below an Off (or missing) engine are reported as skipped.
  • RewriteCond — evaluates each condition against the current request, expanding variables such as %{REQUEST_URI}, %{HTTP_HOST}, %{HTTPS}, and %{QUERY_STRING}, including negated patterns like !^www\..
  • RewriteRule — matches your pattern against the path, expands capture groups ($1$9 and $0), and applies flags including [L] (last) and [R=301] / [R=302] (redirect).
  • Redirect and RedirectMatch — exact-prefix and regex redirects with their status codes.
  • Header — header directives are recognized and reported in the trace.

How the step-by-step trace works

Enter your .htaccess content and a URL or path (for example /old-page), then run the test. For each directive the tool shows the line number, the rule text, a colour-coded type badge (rewrite, redirect, condition, header), and whether it matched or was skipped — with a plain-English note explaining why. A condition that fails tells you the variable value it compared and the pattern it did not satisfy. A matched rewrite shows the resulting URL; a matched redirect shows the target and status.

At the top, a summary maps your input URL to the final output URL and flags the HTTP status — so you can confirm at a glance that /old-page becomes /new-page with a clean 301, or spot that nothing matched and the URL passed through unchanged.

Why testing rules first matters

A broken .htaccess is one of the more expensive mistakes in technical SEO and site reliability. A redirect that fires with 302 instead of 301 can stall the transfer of ranking signals; a misordered rule can create a redirect chain or an infinite loop; a greedy pattern can catch URLs you never meant to touch. Because Apache evaluates rules in sequence and [L] halts processing, the order of your rules changes the result as much as the rules themselves — which is exactly what a step-by-step trace makes visible.

To get started fast, the tool ships with ready-made snippets for the most common tasks: forcing www, forcing HTTPS, adding or removing a trailing slash, hiding .html extensions, and blocking image hotlinking. Load one, adjust it, and test it against your own URLs.

A simulation, not a live server

This is an honest preview, not a full Apache instance. Filesystem checks — RewriteCond tests like -f, -d, and -e that ask whether a real file or directory exists — cannot be resolved in the browser, so they are approximated (file and directory tests return false, and %{REQUEST_FILENAME} is stood in with the request path). Use the tester to validate the logic and ordering of your rules quickly and privately; then confirm anything filesystem-dependent on your actual server before going live.