Welcome Guest, Not a member yet? Register   Sign In
Error redirection
#1

[eluser]cominus[/eluser]
Please be patient if I have overlooked something obvious. Although I registered here last year I did not begin working with code igniter before this week. So, here goes:

It seems intuitive to me that
Code:
<?php show_error('errors/forbidden', int $status_code=403);
should redirect the page through this controller function ->
Code:
<?php
class Errors extends CI_Controller {

    . . .

    function forbidden()
    {
        $data['page_title'] = 'Error 403';
        $data['page_heading'] = 'Directory access is forbidden!';
        $this->load->view('header', $data);
        $this->load->view('forbidden', $data);
        $this->load->view('footer');
    }
}
instead, it redirects through this controller function ->
Code:
<?php
class Errors extends CI_Controller {

    . . .

    function page_missing()
    {
        $data['page_title'] = 'Error 404';
        $data['page_heading'] = 'The page you are looking for is missing!';
        $data['webmaster_email'] = '[email protected]';
        $this->load->view('header', $data);
        $this->load->view('page_missing', $data);
        $this->load->view('footer');
    }

. . .
}
I am certain this is routing through config/routes ->
Code:
$route['404_override'] = 'errors/page_missing';

What am I missing? or am I attempting the impossible?

Thanks in advance.
#2

[eluser]cominus[/eluser]
It has occurred to me, the code was in a stand-alone index.php file (used to guard over image, css and upload folders). So I have updated the code - but still have the same results.

Here is the update:
Code:
<?php
$CI =& get_instance();
$CI->show_error('errors/forbidden', int $status_code=403);

and I should mention, in the uploads folder, this code (or file) activates the custom error 404 page. In the css and images folders, the browser presents a white screen. All three folders are at the same level on the server.
#3

[eluser]InsiteFX[/eluser]
For one this line should be:
Code:
<?php show_error('errors/forbidden', (int) $status_code=403);

// and this:
<?php
class Errors extends CI_Controller {

    . . .

    function forbidden()
    {
        $data['page_title'] = 'Error 403';
        $data['page_heading'] = 'Directory access is forbidden!';

        $this->load->vars($data);

        $this->load->view('header');
        $this->load->view('forbidden');
        $this->load->view('footer');
    }
}

InsiteFX
#4

[eluser]cominus[/eluser]
Thanks, InsiteFX. However, there is absolutely no change. It looks like two ways of writing the same code. But I thank you anyway for giving me some of your time and thought.
#5

[eluser]KarlBallard[/eluser]
View-source, do you get any of the HTML markup sent back to the browser?
#6

[eluser]cominus[/eluser]
KarlBallard - the HTML comes from the page_missing function and not the forbidden function. That is the problem I am trying to overcome. Thank you for looking at this.




Theme © iAndrew 2016 - Forum software by © MyBB