# Apache rewrite rule tester

- Human page: https://happytails.ai/en/developer-tools/apache-rewrite-rule-tester/
- Markdown: https://happytails.ai/en/developer-tools/apache-rewrite-rule-tester.md
- Structured JSON: https://happytails.ai/agents/en/developer-tools/apache-rewrite-rule-tester/index.json
- Visibility: public

## Tool capabilities

| Property | Value |
| --- | --- |
| Tool ID | `apache-rewrite-rule-tester` |
| Category | developer-tools |
| Implementation | Registered implementation. Registration alone is not a production-quality guarantee. |
| Browser execution | Use the visible action or interactive controls. |
| Browser processing | Browser; see tool notes for network behavior. |
| HTTP API | Not callable through HTTP. |
| Browser-agent interface | run_current_tool |

### Implementation notes

Runs mod_rewrite rules against your test URLs on your device. Up to 200,000 characters of rules and 200 URLs.

### Inputs and settings

Text input: Rewrite rules.

Example or placeholder shown in the interface (not a validated fixture):

```text
RewriteEngine On
RewriteRule ^old/(.*)$ /new/$1 [R=301,L]
```

Paste the rewrite lines from .htaccess or your virtual host. Up to 200,000 characters. Review the settings before running.

| Setting | Meaning | Control type | Default | Constraints |
| --- | --- | --- | --- | --- |
| `requests` | Test URLs | textarea | "" |  |
| `context` | Where the rules live | select | "htaccess" | Allowed: htaccess, server |
| `directory` | .htaccess directory (URL path) | text | "/" |  |
| `existing` | Existing files and folders | textarea | "" |  |

### Browser-agent workflow

1. Open the human page in a browser that supports WebMCP.
2. Discover the interface exposed by that page; use its actual schema.
3. Select files on the page first when the tool requires files.
4. Call `run_current_tool` with valid input and settings.
5. Inspect the returned result or error and the displayed output. Retrieve files from the displayed download links.

Calls do not automatically copy or download results. Browser permissions still apply. Interface availability alone is not proof of successful execution.

### Planning specification

Up to 200,000 characters of rules, 2,000 rules and 200 test URLs. Everything runs on your device in a background worker. Downloads: a plain text trace, a JSON report with every step and a CSV of results.

This describes intended requirements. Use the implementation notes, interface schema and observed output to determine current support.

### Complete machine-readable capability record

```json
{
  "id": "apache-rewrite-rule-tester",
  "category": "developer-tools",
  "built": true,
  "requirements": "Up to 200,000 characters of rules, 2,000 rules and 200 test URLs. Everything runs on your device in a background worker. Downloads: a plain text trace, a JSON report with every step and a CSV of results.",
  "implementation": {
    "fields": [
      {
        "key": "requests",
        "label": "Test URLs",
        "value": "",
        "type": "textarea",
        "help": "One per line, such as https://example.com/old/page?id=3 or /blog. Add headers after | like | User-Agent: test. Up to 200 URLs."
      },
      {
        "key": "context",
        "label": "Where the rules live",
        "value": "htaccess",
        "type": "select",
        "values": [
          "htaccess",
          "server"
        ]
      },
      {
        "key": "directory",
        "label": ".htaccess directory (URL path)",
        "value": "/",
        "type": "text",
        "help": "The URL path of the folder that holds the .htaccess file, such as / or /blog/."
      },
      {
        "key": "existing",
        "label": "Existing files and folders",
        "value": "",
        "type": "textarea",
        "help": "Optional. URL paths that exist on disk for -f and -d tests, one per line. End folders with /."
      }
    ],
    "registrationFamily": "config-directive-linters",
    "inputMaxLength": 200000,
    "inputErrorCode": "CONFIG_DIRECTIVE_LINTERS_TOO_LONG_REWRITE",
    "note": "Runs mod_rewrite rules against your test URLs on your device. Up to 200,000 characters of rules and 200 URLs.",
    "experience": {
      "automatic": false,
      "single": false,
      "inputMaxLength": 200000,
      "inputMode": "text",
      "label": "Rewrite rules",
      "placeholder": "RewriteEngine On\nRewriteRule ^old/(.*)$ /new/$1 [R=301,L]",
      "help": "Paste the rewrite lines from .htaccess or your virtual host. Up to 200,000 characters. Review the settings before running.",
      "action": null
    },
    "mode": "explicit",
    "interactive": false
  },
  "execution": "Browser interface",
  "api": null,
  "browser_agent": {
    "supported": true,
    "name": "run_current_tool",
    "discovery": "WebMCP on the human page in a supporting browser",
    "verification": "See audit/API-AUDIT.md; availability is not verification"
  }
}
```

## Page guide

Run your .htaccess or virtual host rewrite rules against test URLs and see the redirect, internal rewrite or error each one gets, with every rule and condition that matched.

How can we improve this tool?

Report a problem or share an idea.

Please leave out private information. Your message and the tool name go to our team via PostHog.

### How to use Apache rewrite rule tester

1. Paste the RewriteEngine, RewriteBase, RewriteCond and RewriteRule lines.
2. Add test URLs, one per line, and choose whether the rules live in .htaccess or the server configuration.
3. List files and folders that exist if your conditions use -f or -d.
4. Run the test and read the trace, or download the JSON report and CSV.

## Useful next steps

- [Regex tester](https://happytails.ai/en/developer-tools/regex-tester/) ([Markdown](https://happytails.ai/en/developer-tools/regex-tester.md))

- [Redirect checker](https://happytails.ai/en/web-tools/redirect-checker/) ([Markdown](https://happytails.ai/en/web-tools/redirect-checker.md))

- [URL parser](https://happytails.ai/en/developer-tools/url-parser/) ([Markdown](https://happytails.ai/en/developer-tools/url-parser.md))

## How the rules are run

Happytails.ai interprets the rules following the Apache HTTP Server 2.4 mod\_rewrite documentation (httpd.apache.org, read on 16 October 2026). In .htaccess the folder prefix is removed before matching and added back to relative results, RewriteBase applies, and after an internal rewrite the rules run again, up to 10 rounds like LimitInternalRecursion. In the server configuration each URL goes through the rules once. The query string is kept unless the substitution brings its own, QSD is set or the substitution ends with ?, and QSA adds the old query to a new one. An absolute URL with the same scheme, host and port as the request is served internally, as when ServerName names that port; any other absolute URL is a redirect, 302 unless R gives a code. Redirect locations are escaped the way Apache escapes them unless NE is set.

### Conditions, references and flags

RewriteCond supports regular expressions, negation with !, lexical and number comparisons, \[NC\] and \[OR\]. As in Apache, a chain of \[OR\] conditions stops at its first true condition. Substitutions expand $1 from the rule, %1 from the last matching condition and %{VARIABLE} values such as HTTPS, HTTP\_HOST, REQUEST\_URI and QUERY\_STRING. The flags L, END, R, NC, QSA, QSD, QSL, NE, F, G, C, S, N, PT, P, E, B, BNP, BCTLS and BNE are applied, including several E flags on one rule with references in their values.

### Limits

Apache uses PCRE and this page uses JavaScript regular expressions. Most patterns behave the same; patterns with possessive quantifiers, atomic groups, \\A, \\Z or inline flags are reported instead of guessed. RewriteMap, other modules such as mod\_alias, and the real file system are not available, so -f and -d use the paths you list.
