Welcome Guest, Not a member yet? Register   Sign In
Problem with redirect and routes
#1

Please,
someone can explain me (as i'm six years old) how to work routing on CI4? I have read entaire documentation and every post in this forum but apparently nothing work. Probably i have lost some parts or i don't know.

I have 2 pages.

in second pages if is present a specific condition i would to redirect the user to first page, so:

redirect()->route('landing');


In this moment i put the redirect in __constructor of Controller, to test the redirect. Nothing, redirect is completly ignored, controller continue to live as redirect not exists.Oviusly i have tested all variants of redirect( ES: redirect()->route('/landing')redirect()->to('landing');).
Only in the first variant i recive this error: route cannot be found while reverse-routing .

In my Routes.php i have added:

$routes->add('a, 'ControllerA::index');
$routes->add('b', 'ControllerB::index');


Oviusly if i use the classic "header:location......." all work but i think that's is important use the CI4 routing for other particular situation

I hope that someone can help me, thanks
Reply


Messages In This Thread
Problem with redirect and routes - by Madsex - 03-26-2021, 10:25 AM
RE: Problem with redirect and routes - by Madsex - 03-27-2021, 04:05 AM
RE: Problem with redirect and routes - by mlurie - 03-27-2021, 07:39 AM
RE: Problem with redirect and routes - by wdeda - 03-27-2021, 09:03 PM
RE: Problem with redirect and routes - by Madsex - 03-28-2021, 04:47 AM



Theme © iAndrew 2016 - Forum software by © MyBB