Forum Moderators: phranque
Here the simple .htaccess file
---
RewriteEngine on
RewriteRule ^1\.html$ 2.html [L]
RewriteRule ^2\.html$ 3.html
---
In the folder presents files: 1.html, 2.html and 3.html
According of mod_rewrite docs flag [L] "Stop the rewriting process here and don't apply any more rewriting rules".
So, if I request 1.html I expect to get content of 2.html. But in practice both rules applied and I get content of 3.html. Here this example:
http://www.4oru.org/test/1.html
I have tested this on Apache/1.3.34 on linux and windows.
Why [L] flag don't working? What I do wrong?
In order to solve your problem, you must use RewriteCond and the variable THE_REQUEST to examine the original client (browser) request, and apply the rule only on the first pass through mod_rewrite.
FYI, the contents of THE_REQUEST might be:
GET /2.html HTTP/1.1
so make sure to account for the method, spaces, and protocol in the RewriteCond pattern.
Jim