URL:example.com/bikes/cityname/makename
我的路由配置如下
$route['bikes'] = 'bikes/index';
$route['bikes(/:any)'] = 'bikes/bike_details$1';
$route['bikes/(:any)/(:any)'] = 'bikes/index';
我有这个控制器
public function index($city='',$make='')
{
echo $city."--".$make;
// these two are empty
我在下面尝试过,给我错误
public function index($city,$make)
{
// not working
这对双方都应该起作用
example.com/bikes/cityname/makename
和
example.com/bikes/
答案 0 :(得分:0)
希望这对您有帮助:
route.php
应该是这样的:
$route['bikes/index'] = 'bikes/index';
$route['bikes/(:any)'] = 'bikes/$1';
$route['bikes/(:any)/(:any)'] = 'bikes/$1/$2';
更多信息:https://www.codeigniter.com/user_guide/general/urls.html