Skip to content
Plumb
Light theme onCheck a URL

DocsCrawling

.htaccess Tester

Run Apache rewrite and redirect rules against a URL and see, line by line, which rules match and where the request ends up.
  • mod_rewrite and mod_alias
  • Runs in your browser
  • Shareable link

What it Checks

The tester evaluates your rules as a .htaccess file in the document root, for a request to the URL you enter, the way Apache processes it: mod_rewrite first, then mod_alias, then another pass after an internal rewrite. It supports RewriteEngine, RewriteBase, RewriteCond (regular expressions, -f/-d tests, comparisons, [NC] and [OR]), RewriteRule with back-references ($1, %1) and the flags L, END, R, NC, QSA, QSD, NE, F, G, S, C and E, plus Redirect, RedirectMatch, RedirectPermanent and RedirectTemp.

You get the outcome (a redirect with its status, an internal rewrite, a refusal or no change), the final URL, and a trace of every line with the reason it matched or didn't.

Run a Test

  1. Paste your rules into the editor. An example with an HTTPS and www redirect is loaded to start with.
  2. Enter the URL to test. Without a scheme, http:// is assumed.
  3. Press Evaluate (or ⌘ ↵ in the editor). The result opens with the outcome: Redirects 301., Rewritten., Forbidden., Gone., Rewrite loop. or No rule matches.
Open the .htaccess Tester

Options

  • Method. The value of %{REQUEST_METHOD} (and of %{THE_REQUEST}). GET by default.
  • User agent. The value of %{HTTP_USER_AGENT}: none, a preset (Googlebot Smartphone, Bingbot, GPTBot, Chrome, Safari on iPhone) or a custom string, for rules that treat bots or phones differently.
  • Referer. The value of %{HTTP_REFERER}, for rules that block hotlinking or treat some referrers differently. Empty by default.
  • Server name. The value of %{SERVER_NAME}. When empty, it is the host of the URL.
  • Paths that exist on disk. One URL path per line, folders ending with /. -f and -s are true for listed files, -d for listed folders and every parent of a listed path (and /), -U for either; -l and -x are always false. With nothing listed, every path is missing.
  • Other request headers. Name: value lines, for %{HTTP_COOKIE}, %{HTTP_ACCEPT_LANGUAGE}, %{HTTP_ACCEPT}, %{HTTP:Name} and the like.
  • Copy link. Copies a link that carries the rules, the URL and every field, so someone else opens the same test. The data sits in the part of the link after #, which browsers don't send to the server.

Reading the Result

  • Final URL: where the request ends up. For an internal rewrite, the visitor's address doesn't change; the server serves the final URL instead.
  • Status: the redirect or error code, or 200 · internal rewrite / 200 · unchanged.
  • Passes: how many times the file ran. Each internal rewrite makes Apache run the file again for the new URL.
  • Matched rules: the line numbers of the RewriteRule and Redirect lines that matched.
  • Line by line (or Pass 1, Pass 2… when the file ran more than once): each line with its status and a short explanation, such as "off" ~ off for a condition or Redirect (301) to https://www.example.com/ for a rule.

The status of each line:

StatusMeaning
metThe condition is true, or the rule matched and was applied.
not metThe pattern didn't match, or a condition of the rule failed.
not reachedAn earlier rule stopped processing, the rule was skipped by [S] or a broken chain, or RewriteEngine is off.
invalidA syntax error, an invalid regular expression, or a RewriteCond with no rule after it.
infoA setting (RewriteEngine, RewriteBase) or a directive that isn't a redirect or rewrite (Header, ErrorDocument…).
ignoredAn unknown directive, or a <Files>, <Directory> or <If> block whose condition isn't evaluated (the lines inside it are still tested).

Good to Know

  • After an internal rewrite (with or without [L]), Apache runs the file again for the new URL. The tester does too, until a pass changes nothing, [END] stops rewriting, or 10 passes are reached, which Apache answers with a 500 (LimitInternalRecursion). In later passes %{ENV:REDIRECT_STATUS} is 200, as rules that stop loops expect.
  • [R] without [L] keeps processing the rules below, which can still change the target, like Apache. An absolute URL on the same scheme and host without [R] is an internal rewrite; on another host it redirects.
  • File tests use the paths you list (see Options). Variables the tester doesn't know read as empty, as in Apache, and the line says so.
  • Not evaluated: <If>, <Files> and <Directory> conditions (their lines are tested as if the block applied), RewriteMap (not allowed in .htaccess), proxying ([P]) and .htaccess files in subdirectories.
  • Everything runs in your browser: the rules and URL are not sent anywhere. To see the redirects a live site really answers, use Fetch & Render.

API

There is no API: the evaluation runs in the page. To share or save a test, use Copy Link. The link has this form, where the part after #t= is the test (rules, URL and the request fields) as Base64-encoded JSON:

Shared Link
https://plumb.reacthive.dev/tools/htaccess#t=eyJydWxlcyI6IlJld3JpdGVFbmdpbmUgT24uLi4iLCJ1cmwiOiJodHRwOi8vZXhhbXBsZS5jb20vYmxvZy9oZWxsbyIsInJlZmVyZXIiOiIiLCJzZXJ2ZXJOYW1lIjoiIn0=
Decoded
{
  "rules": "RewriteEngine On...",
  "url": "http://example.com/blog/hello",
  "referer": "",
  "serverName": "",
  "userAgent": "",
  "method": "GET",
  "headers": "Cookie: lang=fr",
  "existing": "/index.php
/wp-content/"
}