.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
→ /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
Meta Tag Generator
Build SEO title, description, and viewport meta tags.
Open Graph Generator
Generate Open Graph and Twitter Card meta tags.
Robots.txt Generator
Build a robots.txt file with per-bot rules. Block AI crawlers, set crawl delays, define sitemaps.
UTM Campaign URL Builder
Append UTM parameters to build trackable campaign URLs.
Hreflang Tag Generator
Generate hreflang link tags for multilingual SEO.
Sitemap XML Generator
Build an XML sitemap from a list of URLs.
SERP Snippet Preview
Preview how your page title and meta description appear in Google search.
Meta Tag Analyzer
Paste a page's HTML head to audit its title, meta, and social tags.