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
- Paste your .htaccess or rewrite rules.
- List test URLs, with => and the result you expect if you like.
- List the files and folders that exist, for -f and -d conditions.
- 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.