Apache Rewrite Rule Tester
Test .htaccess mod_rewrite RewriteRule and RewriteCond patterns in your browser — see the rewritten URL, status, flags and a step-by-step trace.
Advertisement
Test Before Applying
Generated configuration is a starting point. Always:
- Test in a non-production environment
- Validate syntax before reloading services
- Keep a backup of your working config
- Adapt to your specific server setup
SysAdmin Tools provides this as a reference only and is not responsible for service interruptions.
Enter the URL you want to test
Advertisement
Related: .htaccess Generator →
Advertisement
This Apache rewrite rule tester simulates mod_rewrite in your browser so you can check how a RewriteRule or RewriteCond behaves before deploying it. Paste a test URL and your .htaccess rules, hit Test, and see the rewritten URL, the HTTP status, the flags that fired, and a step-by-step trace of every rule evaluated.
Apache's mod_rewrite is famously hard to debug: a pattern that looks right can silently fail to match, loop, or redirect to the wrong place. This mod_rewrite tester parses RewriteEngine, RewriteRule and RewriteCond directives, supports common flags (R, L, NC, QSA, NE, P), evaluates backreferences ($1, %1), and shows you exactly which rule changed the URL. Quick-start templates cover 301 redirects, removing .php, forcing HTTPS, www/non-www and trailing-slash rules.
Because it runs entirely client-side, no request ever leaves your browser. It is a learning and debugging aid — always confirm behaviour on your real Apache server before relying on it in production.
How to Use the Apache Rewrite Tester
- 1
Enter a test URL
Type the URL you want to check, such as https://example.com/old-page. The path and query string are extracted and fed into the simulator as the incoming request.
- 2
Add your rewrite rules
Paste your RewriteEngine, RewriteCond and RewriteRule lines into the rules box, or load a quick template (301 redirect, remove .php, force HTTPS, www to non-www, remove trailing slash).
- 3
Set server variables (optional)
Open the advanced panel to set HTTP_HOST, the HTTPS on/off state, HTTP_USER_AGENT and QUERY_STRING so RewriteCond directives that test those variables evaluate correctly.
- 4
Run the test
Click Test Rewrite Rules. The result card shows whether a rule matched, the input and output URL, the status code and the active flags.
- 5
Read the trace
Review the step-by-step trace to see each rule evaluated, which pattern matched, and what each flag did — then adjust your rules and re-test.
Understanding mod_rewrite Rules
mod_rewrite ruleset processes the requested URL path top to bottom. Each RewriteRule has a pattern (a regular expression matched against the path), a substitution (the replacement, or - for no change), and optional flags in square brackets. A rule can be preceded by one or more RewriteCond directives, which are extra conditions (often testing server variables like %{HTTPS} or %{HTTP_HOST}) that must all pass for the following rule to apply.
Flags control what happens. [R=301] issues an external redirect with that status; [L] stops processing further rules; [NC] makes the pattern case-insensitive; [QSA] appends the original query string to the substitution; [NE] prevents escaping of special characters; and [P] proxies the request. Patterns capture groups that you reference in the substitution as $1, $2 (from the RewriteRule) and %1, %2 (from the last matching RewriteCond).
This simulator applies those rules to the path you provide and reports the outcome. It is a close approximation for common redirect and rewrite scenarios, but real Apache has subtleties — per-directory context stripping the path prefix, repeated passes through the ruleset, interaction with other modules — that a browser cannot perfectly reproduce. Use it to understand and sanity-check rules, then verify on the server.| Field | Description |
|---|---|
| RewriteEngine | Turns rewriting on or off; rules are ignored unless RewriteEngine On is present. |
| RewriteRule | A pattern, a substitution and optional flags — the core rewrite/redirect instruction. |
| RewriteCond | A condition tested before the following RewriteRule; all conditions must pass for the rule to run. |
| [R=301] | Performs an external redirect with the given status (301 permanent, 302 temporary). |
| [L] | Last rule — stops processing the remaining rules once this one matches. |
| [NC] | No case — makes the pattern match case-insensitively. |
| [QSA] | Query String Append — keeps the original query string on the rewritten URL. |
| $1 / %1 | Backreferences to captured groups from the RewriteRule ($) and the last RewriteCond (%). |
Advertisement
Common Rewrite Testing Use Cases
Verify a 301 redirect before deploy
Confirm that an old URL redirects to the new one with the correct 301 status and no accidental loop, so SEO link equity is preserved and visitors are not bounced incorrectly.
Debug a rule that is not matching
Use the step-by-step trace to see why a RewriteRule pattern fails to match a path — a missing anchor, a wrong escape, or a RewriteCond that is quietly failing.
Check HTTPS and www canonicalisation
Test force-HTTPS and www/non-www rules against several URLs to ensure every variant lands on the single canonical form you intend.
Learn mod_rewrite safely
Experiment with patterns, flags and backreferences and watch the result instantly, without touching a live server or risking a site-wide redirect loop.
Apache Rewrite Rule Tester — Frequently Asked Questions
What is Apache mod_rewrite?
How to test Apache rewrite rules online?
What is the difference between 301 and 302 redirect in Apache?
How to write a RewriteRule in .htaccess?
What does RewriteCond do in Apache?
How to redirect www to non-www in Apache?
How to force HTTPS in .htaccess?
What are Apache RewriteRule flags?
How to remove .php extension with mod_rewrite?
How to debug Apache rewrite rules?
Is this simulator exactly the same as real Apache?
Related Tools
.htaccess Generator
Generate the .htaccess redirect, caching and security rules you then test here.
Nginx Config Generator
Build the Nginx equivalent if your host runs Nginx instead of Apache.
Redirect Checker
Trace the live redirect chain of a URL once your rules are deployed.
Security Headers
Audit the security headers your server returns alongside rewrites.