Why not consolidate these into '/?version/'? Since the regex will consume all alphanumerics (or alphanumerics plus periods) prior to the /version, there's no risk that foo.bar.version/branch will be grabbed as matching the version regex.