Php CodeIgniter路由和正则表达式
我正在尝试在CodeIgniter上创建一个路由,它匹配3个数字,后面跟一个连字符,后面跟任何东西。到目前为止,我一点运气都没有。我尝试了以下方法:Php CodeIgniter路由和正则表达式,php,regex,codeigniter,routes,Php,Regex,Codeigniter,Routes,我正在尝试在CodeIgniter上创建一个路由,它匹配3个数字,后面跟一个连字符,后面跟任何东西。到目前为止,我一点运气都没有。我尝试了以下方法: $route['([0-9]+)-([a-zA-Z0-9]+)'] = 'product/index/$1'; $route['([0-9]+)([a-zA-Z0-9-]+)'] = 'product/index/$1'; $route['(:num)-(:any)'] = 'product/index/$1'; $route['([0-9]{3}
$route['([0-9]+)-([a-zA-Z0-9]+)'] = 'product/index/$1';
$route['([0-9]+)([a-zA-Z0-9-]+)'] = 'product/index/$1';
$route['(:num)-(:any)'] = 'product/index/$1';
$route['([0-9]{3})-(:any)'] = 'product/index/$1';
$route['(\d{3})-(:any)'] = 'product/index/$1';
等等。有人知道我怎么做吗?看起来CodeIgniter没有使用标准的正则表达式
试试这些:
\d{3}\-*
\d{3}-*
\d{3}\-:任何
\d{3}-:任何
其中一个应该有效
有关更多信息,请参见,这可能是一个参数问题。 也许你应该试试:
$route['([0-9]+)-([a-zA-Z0-9]+)'] = 'product/index/$1/$2';
既然您正在捕获两个变量,似乎应该将它们都传递给函数。为什么同一页有5条路由?