How to use the .htaccess tester
- 1Paste your rules into .htaccess rules, or press Example. Rules made with the .htaccess redirect generator arrive here automatically from its link.
- 2Enter the full URL to test, including
http://orhttps://. Optionally set the Request method, User agent and Referer. - 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
-fand-dconditions behave as on your server. - 4Read the Result (redirect, internal rewrite, 403, 410 or unchanged) and the table showing each line's result and why.
- 5To check many addresses at once, paste them into Test several URLs, one per line, and press Copy results to take the summary.
Example
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/hello301 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:
| Variable | Value 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
| Flag | Effect |
|---|---|
L | Last: stop processing rules in this pass |
R=301 | Redirect with this status (plain R is 302) |
NC | Case-insensitive pattern |
QSA | Append the original query string to one in the substitution |
QSD | Discard the original query string |
NE | Don't escape the substitution |
F / G | Respond 403 Forbidden / 410 Gone |
S=n | Skip the next n rules |
END | Stop 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.htaccessfiles 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
NEisn'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.
