我有这个:
$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";
}
}
第一条路线完美无缺,而第二条路线则不然。她应该打电话给国家级方法,但不打电话!
url:
http://foo.bar/SP/ ---> OK
http://foo.bar/SP/SANTOS - > 404!
答案 0 :(得分:4)
删除锚点到字符串末尾的$
:
$route['^[a-zA-Z]{2}/(:any)'] = "state/city";