我这样设置默认控制器
$route['default_controller'] = "InterviewController";
所以这里是 InterviewController 的代码
class InterviewController extends CI_Controller{
private $em;
function __construct() {
parent::__construct();
}
public function index() {
$commentsList = array();
$commentsList['comments'] = $this->em->getRepository('Entities\Comment')->findPage(1, 10, 'DESC', $this->em->getRepository('Entities\Interview')->getLast()[0]->getId());
$lastInterviewsAnons = array();
$lastInterviewsAnons['lastInterviewsAnons'] = $this->em->getRepository('Entities\Interview')->getLast();
$this->load->view('header');
$this->load->view('navbar');
$this->load->view('content', $lastInterviewsAnons);
$this->load->view('addCommentPanel');
$this->load->view('commentsList', $commentsList);
$this->load->view('footer');
}
}
在我的本地机器上一切正常,但在服务器上我得到 404 错误。我只能通过输入完整的 url 来访问这个控制器,比如http://mydomain.com/index.php/InterviewController。似乎路由文件中的指令不起作用。你有什么建议?