Welcome Guest, Not a member yet? Register   Sign In
custom 404 page
#3

(11-30-2016, 01:38 PM)neodite Wrote: How do you have your controller setup? Do you have your controller named "error" and then function called "error404"? As 200 is a success response....

I have mine setup as a main controller (main.php) with all the default pages (Including error pages)

So controller main.php

PHP Code:
defined('BASEPATH') OR exit('No direct script access allowed');

class 
Main extends CI_Controller {
 
   public function __construct() {
 
       parent::__construct();
    }

    public function 
error_404() {
        
$data['page_name'] = '404 Not Found';

        
$this->load->view('static/header'$data);
        
$this->load->view('static/404');
        
$this->load->view('static/footer');
 
   }

I have more stuff for if user is logged in etc. but this is the basics of it.

Hi

yeah the controller is named error with a function named error404

Everything is working except, if you look into google chrome network inspector you will see this page when loaded is not a true 404 status, its a 200 becasue its a page that is being loaded, rather than the default 404 page that is called when a destination cant be found on the server.

SO I added the status 404 to the function and then everything seemed fine, as google was reporting the custom 404 page was indeed a status of 404..

However anything that is not in routes, or is not findable through controller / method is now also being reported as a 404 (as far as i can gather) which means the admin folder which is not part of the CI installation will no longer load its content?

Not sure how to fix this?

Paul
Reply


Messages In This Thread
custom 404 page - by Paul1972UK - 11-30-2016, 08:13 AM
RE: custom 404 page - by neodite - 11-30-2016, 01:38 PM
RE: custom 404 page - by Paul1972UK - 12-01-2016, 09:14 AM
RE: custom 404 page - by wolfgang1983 - 12-01-2016, 02:17 PM
RE: custom 404 page - by Paul1972UK - 12-02-2016, 05:22 AM



Theme © iAndrew 2016 - Forum software by © MyBB