我这样设置笨2:越来越默认控制器上的404错误
$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访问此控制器。看起来像路线文件中的指令不起作用。你可以建议什么?
检查你的mod重写和你的文件名大小写。你的文件名应该是小写字母,你的URI也是。 – Timmetje 2013-03-25 10:06:50
mod重写已启用。我将我的文件名改为小写。将路由规则更改为$ route ['default_controller'] =“interviewcontroller”;.无论如何,我有404 – 2013-03-25 10:11:05
请发布与此路由相关的.htaccess文件的内容 – 2013-03-25 10:13:56