我有 3 个控制器,分别是家庭、食物和饮料。家庭控制器我想制作默认控制器。我在 routes.php 文件中这样写:
$ route ['default_controller'] = "home";
$ route ['404_override '] ='';
然后我在每个控制器中编写了如下代码:
控制器 home.php
class Home extends CI_Controller{
public function __construct() {
parent::__construct();
}
public function index(){
}
public function info(){
}
}
控制器 food.php
class Food extends CI_Controller{
public function __construct() {
parent::__construct();
}
public function index(){
}
public function foodMenu(){
}
public function foodJenis(){
}
}
控制器drink.php
class Drink extends CI_Controller{
public function __construct() {
parent::__construct();
}
public function index(){
}
public function drinkMenu(){
}
public function drinkJenis(){
}
}
我想让这个网址像 www.mydomain.com/home、www.mydomain.com/food、www.mydomain.com/food/foodmenu、www.mydomain.com/food/foodjenis、www.mydomain.com/drink , www.mydomain.com/drink/drinkmenu, www.mydomain.com/drink/drinkjenis。
但是当我在网址 www.mydomain.com/food/foodmenu 上时,我前往 www.mydomain.com/food/foodjenis,但出现的网址是 www.mydomain.com/food/food/foodjenis。“食物”控制器名称在 url 中一分为二。如何处理它。请帮我。谢谢你 :(