Welcome Guest, Not a member yet? Register   Sign In
How to show 404 whenever/wherever I want
#4

(04-15-2020, 10:19 AM)Leo Wrote: That code does't work for me. The whole syntax
return redirect()->to('/wherever');
is not working for me, at least not in that controller. But even if it did wouldn't it just redirect to /errors/nodata ??
I don't want to redirect though. I just want to show 404 page not found with the uri they were trying to access.

Scenario: They are an unauthorized user probing through my site, theres a url called /edit_products - that should only be viewable by admins.
If they are unauthorized as an admin they see 404 on that link.

There are options through .htaccess, also.

/errors/nodata => It was just an example, I don't know if 404 routing is customized by you.
I warned you that my 404 page is customized.
I changed the router configuration in app/config/routes.php
PHP Code:
$routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('Home');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$routes->set404Override(function()  // <= changed
{
    $header = array (
    'icon' => 'favicon',
    'css' => 'nodata',
    'title' => 'Page not found - wdeda',
    'placeholder' => 'Search'
    );
    
    
echo view('templates/headerr'$header);
    echo view('/content/error_404');
    echo view('templates/footer');
    });
$routes->setAutoRoute(true); 
Reply


Messages In This Thread
How to show 404 whenever/wherever I want - by Leo - 04-15-2020, 08:04 AM
RE: How to show 404 whenever/wherever I want - by wdeda - 04-15-2020, 11:52 AM



Theme © iAndrew 2016 - Forum software by © MyBB