Forum Moderators: phranque
After reading the section about the `very inefficient construct "(.*)/(.*)"` I have a question about other methods. If the directory structure is limited to a specific character range, is it more or less efficient to specify those characters?
In other words, if I only allow numbers in a directory, which choice is more efficient:
/([^/]+)/
/([0-9]+)/
I see a benefit to the latter because it is an extra "validation" step prior to the script being invoked, but if the script is validating anyways (as it should) can I save Apache processor cycles by switching to the former?
But I think that either one would be about the same, and I'd opt for whichever you consider to be easiest to maintain. Your 'validation' concern is also a factor -- Do you want invalid requests passed to the script so that you can handle them 'elegantly' -- or to be rejected by the rewriterule, and allowed to throw a 404 error?
If, however, the the [0-9] needed to be expanded to [0-9a-z], then the advantage would go to [^/] because [0-9a-z] requires *two* range compares instead of one. Think about coding the pattern-matching routine in 'C' or a similar language, and performance-affecting factors become clearer.
Jim