[英]How to call custom 404 page from view using codeigniter?
I want to call 404 page if anyone try to redirect wrong url. 如果有人尝试重定向错误的网址,我想拨打404页面。
i have create a 404 page in my view folder. 我已经在我的视图文件夹中创建了一个404页面。
structure : 结构体 :
---View
---backend
---404.php
how can i call this 404.php page when wrong url call ? 错误的网址调用时如何调用此404.php页面?
1) Create controller name "Notfound.php" in \\application\\controllers. 1)在\\ application \\ controllers中创建控制器名称“ Notfound.php”。
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Notfound extends CI_Controller {
public function index()
{
$this->load->view('404page');//load view
}
}
2) in \\application\\config\\routes.php add $route['404_override'] = 'Notfound';
2)在\\ application \\ config \\ routes.php中添加
$route['404_override'] = 'Notfound';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.