---- .htm to Extensionless URLs - Plus Renaming Files
Dideved - 12:13 am on Jun 26, 2013 (gmt 0)
#7 RewriteRule ^(([^/]+/)*[^./]+)$ /$1.htm [L]
Rule #7 will probably run faster if you express the pattern as ^([^.]+[^./])$
I feel like there should be an informal rule around here that any talk of performance must come with a benchmark to back it up, because people's gut feelings are notoriously unreliable. And I truly don't mean that as an insult against anyone in particular. This is such a widespread problem in the whole field of computing that it's discussed in some of the most renowned books:
It is often a mistake to make a priori judgments about what parts of a program are really critical, since the universal experience of programmers who have been using measurement tools has been that their intuitive guesses fail. - Knuth
I actually bothered to benchmark the OP's pattern, Lucy's alternative, as well as a .* variation, and they all fell within each other's range of variability. That is, on some runs, OP's pattern was faster; on some runs, Lucy's was faster; and -- yes -- on some runs, even .* was faster. (The .* pattern came with the added benefit that it would work correctly for all valid URLs.)
In addition to none of these patterns being a clear performance winner, it's also worth mentioning that the difference between them was always measured not even in microseconds, but nanoseconds. That difference is so infinitesimally small that for all practical purposes, there is no performance difference.