Apache and Nginx Rewrite Rule Tester

Test Apache RewriteRule and RewriteCond, Redirect and RedirectMatch, or nginx rewrite, return, location, if and try_files against many URLs at once. Every URL shows the final status code, the redirect target or internal path, and a line-by-line trace with captures, so you can fix a redirect loop before it reaches production.

Runs in your browser. Your files never leave your device. See how to check

…

How to do it

  1. 1
    Choose the server

    Tap Apache or nginx, and for Apache choose .htaccess or VirtualHost context and the folder the .htaccess sits in.

  2. 2
    Paste the rules

    Paste your .htaccess, httpd.conf section or nginx server block; errors such as missing semicolons are marked with their line.

  3. 3
    Describe the server

    Under Request and file system list the files and folders that exist and set headers if your rules test them.

  4. 4
    Add test URLs

    Enter one URL per line, full or path only, and add -> 301 https://target to check an expected result.

  5. 5
    Read the trace

    Tap a URL to see each directive in order, what matched, the captures and the final status and URL.

  6. 6
    Save and share

    Save the project, export it as JSON, download the rules or print the results table as a PDF.

About this tool

Rewrite rules are small but unforgiving. One missing [L] flag, a RewriteCond that applies to the wrong rule or a location block that nginx never selects can send visitors into a redirect loop, drop the query string or serve the wrong page, and you usually find out from a search console warning weeks later. This tester runs the rules the way the server does, inside your browser. For Apache it reads RewriteEngine, RewriteBase, RewriteCond and RewriteRule with their flags, plus the mod_alias directives Redirect, RedirectMatch, RedirectPermanent and RedirectTemp. You choose whether the rules sit in an .htaccess file, where Apache strips the folder prefix and runs the list again after every internal rewrite, or in a VirtualHost, where the pattern sees the full path once. For nginx it reads a server block with nested location blocks of every kind (exact, ^~ prefix, case-sensitive and case-insensitive regex, plain prefix), rewrite with last, break, redirect and permanent, return, if conditions, set, break and try_files, and it repeats the location search after a last flag or a changed URI, stopping after ten cycles like the real server. Paste as many URLs as you like, each with an optional expected result such as -> 301 https://example.com/new, and the tester marks every line pass or fail. A list of files and folders that exist lets -f, -d and try_files behave as they would on your server, and request values such as the User-Agent, Referer, cookie, method and client IP feed the matching server variables.

What you see for every URL

The final HTTP status, whether the request ends as an external redirect, an internal rewrite, an error such as 403 or 410, or a direct response from return. Open a row for the trace: every directive the server looked at, in order, with the subject string, whether the pattern matched, the value of each RewriteCond test string, the back-references $1 to $9 and %1 to %9, variables set with [E] or set, and the location nginx chose.

Supported directives and flags

Apache RewriteRule flags L, END, R with any 3xx code, NC, QSA, QSD, F, G, C, S, N, NE, PT, B, E and CO; RewriteCond regex, lexical comparisons, integer comparisons, -f, -d and -s, with NC and OR. Server variables include REQUEST_URI, QUERY_STRING, HTTP_HOST, HTTPS, THE_REQUEST, REQUEST_FILENAME, HTTP:header and the common HTTP_ names. nginx variables include $uri, $request_uri, $args, $arg_name, $host, $scheme, $http_name, $cookie_name, $request_filename and regex captures, named ones too.

What is not simulated

RewriteMap lookups, proxying with [P] (the target is shown but not fetched), Directory and Location sections (rules inside are applied to every request), symbolic link tests, nginx map, geo and include files, and modules other than rewrite and core. Regular expressions run on the JavaScript engine, which agrees with PCRE for normal rules but has no possessive quantifiers, atomic groups or recursion; such patterns are reported instead of being guessed.

Tested against

The simulator was checked with our own test cases written from the Apache 2.4 mod_rewrite and mod_alias pages and the nginx rewrite and core module pages (HTTPS and www redirects, front controllers, .htaccess loops, location order, try_files). It was not run side by side with a live Apache or nginx build, so module versions, other modules and server defaults may change results.

Privacy and limits

Nothing is sent to a server. The result is a simulation from the published module documentation, not your server: confirm important changes on a staging host with curl -I before deploying them.

Worked example

A shop moves its blog from /blog/2025/03/spring-sale to /articles/spring-sale and forces HTTPS without www. The .htaccess has four rules. The tester runs seven URLs: http://www.example.com/shop?x=1 returns 301 to https://example.com/shop?x=1 in one hop because the HTTPS and www conditions are joined with [OR]; the old blog URL returns 301 to /articles/spring-sale?y=2025&m=03; /style.css is served directly because it is in the file list; /products/blue-shirt?ref=ad is rewritten internally to /index.php?ref=ad and stops on the second pass because index.php exists; /old-contact is caught by the mod_alias Redirect line. Six of the seven expected results pass; the failing line shows the team wrote 302 where the rule says 301.

Quick facts

Frequently asked questions

Does this tester send my rules or URLs to a server?

No. The simulator is JavaScript running in this tab. Your rules, URLs and file lists stay on your device and are saved only in this browser if you use Save project.

Why does my .htaccess rule loop when the same rule works in the VirtualHost?

In .htaccess Apache runs the whole rule list again after every internal rewrite, so a rule that rewrites everything to index.php also matches index.php. Choose .htaccess context and the trace shows each pass; add a RewriteCond that excludes existing files or use the END flag to stop the loop.

How do I write an expected result?

Put an arrow and the status after the URL, optionally followed by the target: https://example.com/old -> 301 https://example.com/new. Lines without an arrow are tested but not marked pass or fail.

Which nginx location wins?

The tester follows the documented order: an exact = match first, then the longest prefix; if that prefix has ^~ the search stops, otherwise regex locations are tried in the order they appear and the first match wins, falling back to the longest prefix. The trace lists every location it checked.

Can it test redirects that depend on the user agent or a cookie?

Yes. Open Request and file system, set the User-Agent, Referer, Cookie, method or client IP, and conditions on the HTTP_USER_AGENT server variable, $http_user_agent, $cookie_name and similar variables use those values.

Is the result guaranteed to match my server?

It follows the Apache 2.4 and nginx module documentation for the directives listed, but server builds, other modules and included files can change behaviour. Treat it as a fast first check and confirm on a staging server.

Guides for this tool

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages