diff options
author | admin <devnull@localhost> | 2006-08-26 03:15:06 +0200 |
---|---|---|
committer | admin <devnull@localhost> | 2006-08-26 03:15:06 +0200 |
commit | d4e95072203a5cf4f1d50d16fe3e490f275a4307 (patch) | |
tree | edc5497d9a2caa4b4659bff16c2f5068a5012086 /system | |
parent | a634e56d86b965df334e4a431fb0586565ade7a6 (diff) |
Diffstat (limited to 'system')
-rw-r--r-- | system/application/config/routes.php | 2 | ||||
-rw-r--r-- | system/libraries/Router.php | 19 |
2 files changed, 17 insertions, 4 deletions
diff --git a/system/application/config/routes.php b/system/application/config/routes.php index 622bf88e6..5167f7569 100644 --- a/system/application/config/routes.php +++ b/system/application/config/routes.php @@ -46,4 +46,6 @@ $route['scaffolding_trigger'] = "scaffolding"; // Define your own routes below ------------------------------------------- +$route['products\/([a-z]+)\/(\d+)'] = "$1/a$2"; + ?>
\ No newline at end of file diff --git a/system/libraries/Router.php b/system/libraries/Router.php index abc253eff..b61dfb79c 100644 --- a/system/libraries/Router.php +++ b/system/libraries/Router.php @@ -300,16 +300,27 @@ class CI_Router { } // Loop through the route array looking for wildcards - foreach ($this->routes as $key => $val) + foreach (array_slice($this->routes, 1) as $key => $val) { if (count(explode('/', $key)) != $num) continue; - - if (preg_match("|".str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key))."$|", $uri)) - { + + // Convert wildcards to RegEx + $key = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key)); + + // Does the regex match this URI ? + if (preg_match('|^'.$key.'$|', $uri)) + { + // Do we have a replacemnt? + if (strpos($val, '$') !== FALSE AND strpos($key, '(') !== FALSE) + { + $val = preg_replace('|^'.$key.'$|', $val, $uri); + } + $this->_compile_segments(explode('/', $val), TRUE); break; } + } } // END set_method() |