Forum Moderators: phranque
RewriteCond test match
RewriteRule pattern1 substitution1
RewriteRule pattern2 substitution2
I'd like the pattern2 RewriteRule to run ONLY if the RewriteCond is met, but even if pattern1 is not matched. In other words, I want to do something like this:
if (RewriteCond) {
RewriteRule pattern1...
RewriteRule pattern2...
}
But mod_rewrite only seems to do this:
if (RewriteCond){
RewriteRule pattern1...
}
RewriteRule pattern2...
Do I have to repeat the same RewriteCond (or set of RewriteConds) for each rule? I'd appreciate any help. Thanks.
Welcome to WebmasterWorld [webmasterworld.com]!
See the [C] Chain flag for RewriteRule.
Another approach is to force rewriting to stop by detecting the exit case:
RewriteCond <condition to quit under>
RewriteRule .* - [L]
<code for 'else' case goes here>