Start a project

Tool 187 of 194 · Server

Apache mod_rewrite Tester

Find out what your .htaccess rewrite rules really do to a URL before they go live.

Apache mod_rewrite Tester

Rules

Test URLs

Write expectations as 200 /path for an internal rewrite, 301 https://… for a redirect, or a status such as 403.

Results

URLResultRules that actedCheck

    Step by step

    RoundRuleDirectiveMatched againstConditions and result

    Follows Apache 2.4 (checked against httpd 2.4.62): in .htaccess the pattern sees the path without the folder prefix plus any PATH_INFO, relative substitutions get the folder prefix, and after an internal rewrite the rules run again until nothing changes or 10 rounds pass. RewriteMap, mod_alias and -l/-x tests aren't simulated.

    01

    What it does

    Runs your RewriteRule and RewriteCond lines on test URLs the way Apache 2.4 does, shows the redirect or rewrite each one gets, and traces every rule.

    • RewriteRule, RewriteCond and RewriteBase with $1 and %1 backreferences
    • Flags: L, END, R=code, F, G, NC, QSA, QSD, NE, B, C, S, N, E, DPI and OR
    • Server variables such as HTTP_HOST, QUERY_STRING, THE_REQUEST, REQUEST_FILENAME and ENV:REDIRECT_STATUS
    • -f and -d tests against a list of files you give

    02

    Private by design

    Everything happens in your browser. Nothing you type, paste or upload is sent anywhere, and it keeps working offline once the page has loaded.

    03

    What you get

    Result per URL, pass or fail against expectations, and a rule-by-rule trace, with a Copy and a Download button on every result.

    • Apache
    • Redirects
    • SEO
    • Servers

    Why it matters

    mod_rewrite is powerful and hard to predict. In an .htaccess file the pattern never sees the leading slash, a rewrite sends the request through the rules again, a redirect without [L] keeps going, and backreferences can repeat PATH_INFO. Most broken redirects come from one of these.

    This tester follows Apache 2.4 step by step and was checked against a real Apache httpd 2.4.62 on over 500 requests. Give it the rules, the URLs you care about and what you expect for each, and it shows where every URL ends up, which rules acted, and a trace of each pattern and condition.

    How to use it

    1. Paste your .htaccess or rewrite rules.
    2. List test URLs, with => and the result you expect if you like.
    3. List the files and folders that exist, for -f and -d conditions.
    4. Read the result for each URL and open the trace for any that surprise you.

    FAQ

    Why doesn't my pattern with ^/ match in .htaccess?

    In .htaccess the folder prefix, including the leading slash, is removed before matching. Use ^page rather than ^/page, or ^/? to work in both places.

    What's the difference between L and END?

    L stops this round, but in .htaccess a rewritten URL goes through the rules again. END stops rewriting for the request altogether.

    Why do I get a 500 error after adding a rule?

    The rule probably matches its own result, so Apache loops until it hits 10 internal redirects. Exclude the target with a condition, check ENV:REDIRECT_STATUS, or use END.

    Does R=301 without L work?

    It redirects, but the rules after it still run first and can change the target. Add L to send the redirect straight away.

    Work with me

    Want a site that gets these right?

    I build fast, accessible websites and web apps that pass these checks from day one. Tell me about your project and I'll reply personally with honest next steps.

    All developer tools · Back to leej.uk