简体   繁体   中英

How to call custom 404 page from view using codeigniter?

I want to call 404 page if anyone try to redirect wrong url.

i have create a 404 page in my view folder.

structure :

---View
  ---backend
    ---404.php

how can i call this 404.php page when wrong url call ?

1) Create controller name "Notfound.php" in \\application\\controllers.

<?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';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM