ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

404 shows a blank page

January 08, 2010 10:17am

Subscribe [5]
  • #1 / Jan 08, 2010 10:17am

    gRoberts

    298 posts

    Afternoon all,

    For some reason my 404 pages are not showing the default 404 template.

    Instead it shows a completely blank page.

    This happens when you go to a route that doesn’t exist or you call show_404.

    Any idea’s?

    Cheers

    Gavin

  • #2 / Jan 10, 2010 12:53pm

    gRoberts

    298 posts

    Anyone?

  • #3 / Jan 10, 2010 9:08pm

    kikz4life

    77 posts

    use firebug for debugging or log errors, this way you’ll be able to identify the real problems.

    cheers
    -Dean

  • #4 / Jan 11, 2010 11:27am

    gRoberts

    298 posts

    The log see’s it’s 404’ing.. So it’s not something I’d done intentionally.

    Although your reply was useful, does anyone else have any solutions that do not involve installing software?

    Cheers Dean,

    Thanks

    Gavin

  • #5 / Jan 13, 2010 9:39pm

    kikz4life

    77 posts

    do you use .htaccess? i think you already what causing this error. Redirecting to a page that doesn’t exist will sure cause an error. Could you explain more about your problem and also your setup in CI.

    cheers
    -Dean

  • #6 / Jan 15, 2010 9:56am

    gRoberts

    298 posts

    Dean,

    Thanks again for getting back to me.

    I am using .htaccess and everything works great apart from when I try going to a page that doesn’t exist or use the show_404 method, it simply shows a blank page.

    Nothing appears in the log to suggest an error has occurred, as shipped error reporting and display_errors is turned on and to the max.

    The only thing that MAY! be causing it is that my system folder is outside of the htdocs folder. This has not been a problem before?

    Thanks again

    Gavin

  • #7 / Jan 15, 2010 5:04pm

    Jamie Rumbelow

    546 posts

    Interesting, Gavin. Try adding a die() message to the show_404() function in the system/codeigniter/CodeIgniter.php folder to make sure that error is being called. Let me know if it appears!

    Jamie

  • #8 / Jan 15, 2010 5:32pm

    gRoberts

    298 posts

    Evening Jamie.

    Thanks for the head start.

    show_404 in system/codeigniter/Common.php is being called.

    It seems that when setting the http status code via set_status_header($status_code); (CI_Exceptions->show_error) the browser stops sending data.

    I placed a die within the show_404 before the exceptions class is called and it works.
    I place a die after the set_status_header($status_code); and I get nothing.

    Thanks again Jamie.

    Cheers

    Gavin

  • #9 / Jan 15, 2010 5:35pm

    Jamie Rumbelow

    546 posts

    What’s your server configuration? It seems that you’re having an issue with sending the 404 error. I’ve got no idea what, though.

    Jamie

  • #10 / Jan 15, 2010 5:57pm

    gRoberts

    298 posts

    I am running on a domain that was created on a Fasthosts reseller account.

    Whilst trying to get the phpinfo, I decided (since I was on the page) that I’d stick it in the show_404 method and at the bottom, I had the generic error when you output data before sending headers and directly underneath was my 404 page 😉

    Weird :(

    I’ve attached the HTML output I received. - http://sharesend.com/unkjs (sorry about uploading it to some crappy file service but CI’s forum won’t let me upload it)

    For security purposes i have had to remove information regarding the domain/ip address etc. I hope you understand.

    Thanks again Jamie!

    Gavin

  • #11 / Jan 21, 2010 9:41am

    gRoberts

    298 posts

    Any idea’s anyone?

    It seems to be related to my web host as I have now got two CI projects running on the same host with the same issue.

    Cheers

    Gav

  • #12 / Jan 21, 2010 1:37pm

    emily87

    3 posts

    Could be to do with your .htaccess file if you’re using one.

    What happens if you remove/comment out

    <?php header("HTTP/1.1 404 Not Found"); ?>

    at the top of the error_404.php file in the application/errors folder?

  • #13 / Jan 21, 2010 2:38pm

    gRoberts

    298 posts

    I’m using the stock .htaccess file as suggested by the user guide (http://ellislab.com/codeigniter/user-guide/general/urls.html)

    RewriteEngine on
    RewriteCond $1 !^(index\.php|images|assets|robots\.txt|favicon\.ico)
    RewriteRule ^(.*)$ /index.php/$1 [L]

    As for the error_404.php file, it does not contain that code.

    Just FYI, I’m running 1.7.2.

    My show_404 code:

    function show_404($page = '')
        {    
            $heading = "404 Page Not Found";
            $message = "The page you requested was not found.";
    
            log_message('error', '404 Page Not Found --> '.$page);
            echo $this->show_error($heading, $message, 'error_404', 404);
            exit;
        }

    show_error:

    function show_error($heading, $message, $template = 'error_general', $status_code = 500)
        {
            set_status_header($status_code);
            
            $message = ''.implode('
    ', ( ! is_array($message)) ? array($message) : $message).'';
    
            if (ob_get_level() > $this->ob_level + 1)
            {
                ob_end_flush();    
            }
            ob_start();
            include(APPPATH.'errors/'.$template.EXT);
            $buffer = ob_get_contents();
            ob_end_clean();
            return $buffer;
        }

    The first line of show_error seems to be causing the error. If I place a die before set_status_header($status_code); it will throw an error that i am outputting before headers have been sent and then show my 404 page below.

    Also, FYI, i haven’t changed any of the system files or any of the error pages.

    Cheers

    Gavin

  • #14 / Feb 12, 2010 5:22pm

    gRoberts

    298 posts

    I take it no one knows why this is happening?

    By commenting out set_status_header it works. But this won’t send correct 404 headers.

    Any idea’s?

    Cheers

    Gavin

  • #15 / Apr 03, 2010 9:01am

    ciKD

    17 posts

    I ran into a similar problem with 1.7.2 and tests to customize db-error-output, no solution found so far, might be same reason? [SOLVED, was different reason, see posting]

    Posting: As soon as I add header(‘Content-Type: application/x-json; charset=utf-8’); nothing seems to be sent

    As a sidenote, in Exceptions.php, why is $heading not used at all in function show_error($heading, $message, $template = ‘error_general’, $status_code = 500) ? [SOLVED, of course it is used, in include().. ]

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases