php – 在Codeigniter中的路线 – 找不到404页面
发布时间:2020-12-13 17:25:09 所属栏目:PHP教程 来源:网络整理
导读:谁能告诉我,问题出在哪里? 这是我的控制器 class Support extends CI_Controller { public function __construct() { parent::__construct(); $this-load-model('support_model'); $urlarray = array("index","delete"); if(!in_array($this-uri-segment(2)
谁能告诉我,问题出在哪里?
这是我的控制器 class Support extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model('support_model'); $urlarray = array("index","delete"); if(!in_array($this->uri->segment(2),$urlarray)){ $this->viewticket($this->uri->segment(2)); } } public function viewticket($id){ if(!empty($id)){ $this->load->view('templates/logged_header'); $this->load->view('support/view'); $this->load->view('templates/footer'); } } } 这是我的routes.php $route['default_controller'] = "welcome"; $route['benefits'] = 'welcome/benefits'; $route['faqs'] = 'welcome/faqs'; $route['distributors'] = 'welcome/distributors'; $route['contact'] = 'welcome/contact'; $route['purchase'] = 'welcome/purchase'; //login routes $route['login'] = 'login/index'; $route['logout'] = 'login/logout'; $route['404_override'] = ''; localhost / ciproj / support / hello-world给了我404 Page Not Found错误 如果我使用退出;在$this-> load-> view(‘templates / footer’);之后,页面显示空白页面. 我没有任何与支持相关的路线,其他方法都有效 谢谢您的帮助. 解决方法
判断标题,首先检查您的服务器是否使用CGI / FastCGI运行PHP(您可以在
phpinfo() 之前检查一下).
如果是这样,请在config.php中更改以下内容: $config['uri_protocol'] = "REQUEST_URI"; 回到主题,您可以通过在routes.php文件中使用下面的单行路由来实现: $route['support/(?!index)(?!delete)(:any)'] = "support/viewticket/$1"; 并从__construct方法中删除这些行: $urlarray = array("index","delete"); if(!in_array($this->uri->segment(2),$urlarray)){ $this->viewticket($this->uri->segment(2)); } 让我知道它是如何工作的. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |