Welcome Guest, Not a member yet? Register   Sign In
Cannot redirect 404
#1

(This post was last modified: 02-23-2016, 01:26 AM by spider58.)

Hello. I made custom 404 page

routes.php

Code:
$route['404_override'] = 'my404_controller';

application/controllers/my404_controller.php


PHP Code:
class my404_controller extends CI_Controller {
    public function __construct() {
        parent::__construct();
    }

    public function index(){

echo 
'BLAAAAAAAAAA';

global 
$settings; 


$this
->output->set_status_header('404'); 
        $data
['content'] = 'hataaaa'// View name 
        $this->load->view('templates/' $settings->template.'/404.php',$data);//loading in my template 

    }



and 

application/views/templates/default/404.php


Code:
<?php
if(!headers_sent()) header("content-Type: text/html; charset=UTF-8");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9" />
<title></title>

</head>
 
<body>
<h1>Hello</h1>
   
ERRORRRRRRr

</body>

</html>

im calling     show_404(); when article  doesn't exists. But shows codeigniter's error page not my custom 404 view.

The page you requested was not found.

how can i fix it.

thanks inadvance.
Reply
#2

(This post was last modified: 02-23-2016, 01:39 AM by freddy.)

remember you should write with capital every controller, do you use linux or windows ?

please tested it first, then let me know it working or not

and name it  My404_controller.php
Code:
class My404_controller extends CI_Controller {
   public function __construct() {
       parent::__construct();
   }

wait i guess i'm doing wrong
Reply
#3

(This post was last modified: 02-23-2016, 03:25 AM by spider58.)

(02-23-2016, 01:38 AM)freddy Wrote: remember you should write with capital every controller, do you use linux or windows ?

please tested it first, then let me know it working or not

and name it  My404_controller.php
Code:
class My404_controller extends CI_Controller {
   public function __construct() {
       parent::__construct();
   }

wait i guess i'm doing wrong

doesn't worked Sad
Reply
#4

(02-23-2016, 03:25 AM)spider58 Wrote:
(02-23-2016, 01:38 AM)freddy Wrote: remember you should write with capital every controller, do you use linux or windows ?

please tested it first, then let me know it working or not

and name it  My404_controller.php
Code:
class My404_controller extends CI_Controller {
   public function __construct() {
       parent::__construct();
   }

wait i guess i'm doing wrong

doesn't worked Sad

just suggest edit file view error not found if you don't get it
Reply




Theme © iAndrew 2016 - Forum software by © MyBB