Skip to main content
Premier SEO Services

Developer tools

.htaccess Tester

Paste .htaccess rules and a URL to see, line by line, which RewriteCond and RewriteRule directives match, and whether the request is redirected, rewritten or left alone. It simulates Apache; it doesn't contact a server.

  • Runs in your browser
  • Free, no sign-up
  • Unlimited use
  • Updated 30 September 2026

.htaccess Tester

Paste your text to see the numbers update live

  • Simulates RewriteEngine, RewriteBase, RewriteCond, RewriteRule, Redirect, RedirectMatch, RedirectPermanent and RedirectTemp. Other directives are listed as not simulated.
  • Patterns run as JavaScript regular expressions; PCRE-only syntax (possessive quantifiers, atomic groups) is reported as an error.

How to use the .htaccess tester

  1. 1Paste your rules into .htaccess rules, or press Example. Rules made with the .htaccess redirect generator arrive here automatically from its link.
  2. 2Enter the full URL to test, including http:// or https://. Optionally set the Request method, User agent and Referer.
  3. 3Under The requested path is on the server as…, tick An existing file or An existing folder if that is true for this URL, so -f and -d conditions behave as on your server.
  4. 4Read the Result (redirect, internal rewrite, 403, 410 or unchanged) and the table showing each line's result and why.
  5. 5To check many addresses at once, paste them into Test several URLs, one per line, and press Copy results to take the summary.

Example

Input
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,L,NE]
RewriteRule ^blog/(.*)$ /news/$1 [R=301,L]

URL: http://www.example.com/blog/2026/hello
Output
301 redirect to https://example.com/blog/2026/hello
(then, testing that URL: 301 redirect to https://example.com/news/2026/hello)

Two hops: the HTTPS rule matches first and stops with [L]. Moving the blog rule above it, with an absolute https://example.com target, makes it one redirect.

How rules are evaluated

In an .htaccess file, Apache strips the directory prefix and the leading slash before matching, so for https://example.com/blog/post a RewriteRule pattern sees blog/post, not /blog/post. That is the most common reason a rule copied from a server config doesn't match in .htaccess, and the trace shows the exact string each pattern was tested against.

Rules run top to bottom. For each RewriteRule, Apache first tests the pattern and only then its RewriteCond lines, so conditions above a non-matching rule show as not evaluated. A redirect (R) with L ends processing. An internal rewrite with L ends this pass, but Apache then runs the whole file again on the new path, which the tester shows as Pass 2; if the rules keep rewriting, it reports a loop, as Apache would with a 500 error.

RewriteCond and server variables

Each condition tests a string, usually a server variable, against a pattern. The simulator fills these from your request:

VariableValue for http://www.example.com/a?x=1
%{HTTP_HOST}www.example.com
%{HTTPS}off
%{REQUEST_URI}/a
%{QUERY_STRING}x=1
%{THE_REQUEST}GET /a?x=1 HTTP/1.1
%{REQUEST_METHOD}, %{HTTP_USER_AGENT}, %{HTTP_REFERER}from the form

Conditions are joined with AND unless a line has [OR]. ! negates a pattern, = compares exactly, and %1–%9 in the substitution refer to groups from the last matched condition ($1–$9 refer to the rule's own pattern). -f and -d use your answers in the form, since a simulator can't see your server's files.

Flags: L, R=301, NC, QSA

FlagEffect
LLast: stop processing rules in this pass
R=301Redirect with this status (plain R is 302)
NCCase-insensitive pattern
QSAAppend the original query string to one in the substitution
QSDDiscard the original query string
NEDon't escape the substitution
F / GRespond 403 Forbidden / 410 Gone
S=nSkip the next n rules
ENDStop all rewriting, including later passes

Without QSA, a query string in the substitution replaces the original; with no ? in the substitution, the original query is kept. A redirect without L keeps processing later rules, which the tester points out because it is rarely intended.

What a simulator can't test

This is a rule simulator, not your server. It doesn't know:

  • your server configuration: AllowOverride, whether mod_rewrite is enabled, <VirtualHost> rules, or .htaccess files in subfolders;
  • your file system, beyond the file/folder answers you give (after an internal rewrite it assumes paths with a file extension exist);
  • other modules: Header, ErrorDocument, Options, <If> expressions, authentication and caching directives are listed under Not simulated;
  • PCRE features JavaScript lacks, and Apache's escaping of the substitution when NE isn't set.

After uploading, confirm real behavior with the redirect checker, which requests the URL from a server and shows each hop.

Is my text private?

This tool runs entirely in your browser. Your text is not uploaded to our servers.

Sources

Questions about the .htaccess tester

Why doesn't my RewriteRule match?

Most often because the pattern starts with a slash: in .htaccess the path is matched without it, so use ^old-page$, not ^/old-page$. Also check that RewriteEngine On comes first and that an earlier rule with [L] isn't matching.

Is this identical to Apache's behavior?

For the supported directives it follows Apache's per-directory rules: pattern before conditions, [OR] chaining, back-references, query-string handling and repeated passes after a rewrite. Differences come from PCRE vs JavaScript regex details, the file system and server-level settings it can't see.

How do I test on my real server?

Upload the file to a staging copy of the site (or keep the old file ready to restore), then request the URLs with the redirect checker or curl -I, and read Apache's error log if you get a 500.

Learn more

Last updated 30 September 2026Maintained by Premier SEO Services

Report a problem