我有这个:
$route['^[a-zA-Z]{2}$'] = "state";
$route['^[a-zA-Z]{2}$/(:any)'] = "state/city";
这些控制器
state.php
class State extends CI_Controller {
public function index ()
{
echo "OK";
}
public function city ()
{
echo "Not OK";
}
}
第一条路由工作完美,而第二条则不行。她应该调用State的city类方法而不调用!
url:http://foo。bar/SP/--> OK
http://foo.bar/SP/SANTOS -> 404!
删除锚定在字符串末尾的$
:
$route['^[a-zA-Z]{2}/(:any)'] = "state/city";