Htaccess RewriteRule Tester & Validator
Test Apache .htaccess RewriteRule patterns in your browser. Enter a rule and a URL path to see if it matches, what the output URL will be, and what each flag does.
Advertisement
Advertisement
Advertisement
This htaccess rewrite rule tester validates Apache RewriteRule syntax and checks whether a pattern matches a given URL — entirely in your browser. Enter a regex pattern, a substitution with its flags, and a test URL path; the tool tells you instantly if it matches, shows the captured backreferences, builds the resulting output URL, and explains every flag. Nothing is uploaded and no request is sent, so you can debug rules offline-style before touching a live server.
Apache's mod_rewrite is powerful but unforgiving: a single misplaced anchor, an unescaped dot, or a forgotten [L] flag can silently break a redirect. Rather than editing .htaccess, reloading, and guessing, this RewriteRule tester lets you iterate in seconds. It parses the pattern with the browser's own regular-expression engine (the same PCRE-style syntax mod_rewrite uses for the common cases), applies $1, $2 backreferences to the substitution, and decodes flags such as R=301, L, NC, QSA and NE.
Note that in a per-directory .htaccess context Apache strips the leading slash from the path before matching, so a pattern like ^old-page\.html$ matches the request /old-page.html. This tester emulates that by stripping one leading slash from your test URL before matching. It is a learning and debugging aid — always confirm the final behaviour on your real Apache server, especially for complex multi-rule or RewriteCond-driven setups.
How to Use the Htaccess RewriteRule Tester
- 1
Enter the RewriteRule pattern
Type the regular expression from your RewriteRule — for example ^old-page\.html$. This is the part Apache matches against the requested path. Use a quick example from the dropdown if you want a working starting point.
- 2
Enter the substitution and flags
Type the substitution target followed by its flags in square brackets, e.g. /new-page/ [R=301,L]. The tool separates the target from the flags automatically.
- 3
Enter a test URL path
Provide the path part of a URL to test against, such as /old-page.html. The tool strips the leading slash (as .htaccess does) and runs the pattern.
- 4
Read the match result
The Pattern Match Result panel shows MATCH or NO MATCH, lists captured groups ($1, $2, …), and builds the final output URL with backreferences applied.
- 5
Review flags and the full analysis
The Flags Explained panel describes each flag you used, and the Full Rule Analysis panel breaks the rule into labelled pattern, substitution and flag parts. Add a RewriteCond line to have its variables explained too.
Understanding RewriteRule Results
- for no change), and optional flags in square brackets. The rule only acts when the pattern matches. Any parentheses in the pattern create capture groups you can reference in the substitution as $1, $2, and so on — this is how you carry part of the original URL into the destination.
The flags change how the rule behaves. [R=301] turns the rewrite into a permanent external redirect; [R=302] makes it temporary; [L] stops Apache processing further rules; [NC] makes the pattern case-insensitive; [QSA] keeps the original query string; and [NE] stops Apache escaping special characters in the output. This tester reports exactly which flags you used and what each one means so there is no guesswork.
Because .htaccess runs in a per-directory context, Apache removes the leading slash from the path before matching — the tester does the same. Keep in mind that server variables such as %{HTTP_HOST} are resolved by Apache at request time, not by the regex engine, so they appear literally in this tool's output; use the RewriteCond helper to understand what each variable represents.| Field | Description |
|---|---|
| Pattern | The regular expression matched against the requested path (with the leading slash stripped in .htaccess context). |
| Substitution | The rewrite or redirect target. A dash (-) means leave the URL unchanged. Backreferences $1, $2 insert captured groups. |
| Captured groups | Parts of the URL captured by parentheses in the pattern, available as $1, $2, … in the substitution. |
| [R=301] / [R=302] | External redirect: 301 is permanent and cached by browsers, 302 is temporary and not cached. |
| [L] | Last rule — Apache stops evaluating further RewriteRules once this one matches. |
| [NC] / [QSA] / [NE] | Case-insensitive matching, append the original query string, and do not escape special characters, respectively. |
Advertisement
Common RewriteRule Testing Use Cases
Debugging a redirect that is not firing
When a 301 in .htaccess does nothing, the usual cause is a pattern that does not match the real path — often a missing or extra leading slash, or an unescaped dot. Paste the rule and the exact path here to see immediately whether it matches and why.
Checking backreferences before deploying
Rules like ^([^\.]+)\.html$ → /$1/ rely on capture groups. Test them here to confirm $1 captures what you expect and the output URL is correct before you push the change to production.
Learning what each flag does
If you have inherited a cryptic rule with [R=301,L,NC,QSA], the Flags Explained panel decodes every flag in plain English so you understand the rule before editing it.
Validating regex syntax
A malformed pattern makes mod_rewrite fail silently. This tester reports a regex syntax error instead of letting a broken rule reach your server, so you catch mistakes early.
Htaccess RewriteRule Tester — Frequently Asked Questions
What is a RewriteRule in .htaccess?
How do I test an htaccess rewrite rule without uploading to server?
What does the L flag mean in RewriteRule?
What is the difference between R=301 and R=302 in htaccess?
Why is my htaccess RewriteRule not working?
What does NC flag do in Apache RewriteRule?
How do I use backreferences ($1, $2) in RewriteRule?
What is RewriteCond and how does it work with RewriteRule?
How to redirect all traffic to HTTPS using htaccess?
What is the difference between RewriteRule and Redirect in htaccess?
Related Tools
.htaccess Generator
Build complete .htaccess rules for HTTPS, redirects and caching once your pattern is validated.
Apache Rewrite Tester
Simulate a full multi-rule mod_rewrite ruleset with RewriteCond and server variables.
Nginx Config Generator
Translate the same redirect logic into an Nginx server block if you move off Apache.
Redirect Checker
Confirm the live redirect chain on your real server after deploying the rule.