lucy24 - 10:03 pm on Mar 1, 2013 (gmt 0)
In general, chained RewriteConds using [OR] perform better than a regex as benchmarked many years ago by Andreas Friedriech.
That's really not surprising. The essence of an [OR] delimited list is that the moment one condition is met, you can skip to the end of the [OR] cluster. But with a pipe-delimited list you still have to fast-forward to the closing parenthesis-- assuming there was an opening one --which is not so easy if you are a computer operating in one dimension.
Especially when all this is happening in htaccess.
In the case of RewriteRule directives, in .htaccess context these regular expressions must be re-compiled with every request to the directory, whereas in main server configuration context they are compiled once and cached.
I just recently met this line. I may have met it earlier and forgot, so I am trying hard to remember it this time.
But you probably realize I'm thinking from the human user's POV. One slip in cutting-and-pasting or rearranging lines, and your RewriteRule with [OR] conditions brings the whole site crashing down. mod_rewrite will not forgive a trailing [OR] at the end of the last Condition. (It probably won't forgive a trailing pipe creating a null group either, but it's more noticeable.)
It's like minifying. OK, you save a few bytes, but the whole thing becomes unreadable. Besides, the word "minify" makes my skin crawl.
I think everyone who posts regularly in the Apache forum has their own particular boilerplate. Don's happens to be "This discussion belongs in SSID." ;)