-1

I am trying to use redirect in Ci4 and it is not working (loading an empty white page)

In the controller i use the redirect function as follows: redirect()->to('login')

And in the routes.php file i have the route named as follows: $routes->get('login', "Home::login");

When i go with the browser directly to where i should land the page is loaded so it is not a page problem. Secondly in the debug bar since i am in development in the routes tab i can see the route defined

Combinu
  • 882
  • 2
  • 10
  • 31
  • Does this answer your question? [(CI 4) How to redirect within Controller?](https://stackoverflow.com/questions/64969223/ci-4-how-to-redirect-within-controller) – steven7mwesigwa Jan 05 '23 at 10:23
  • Duplicate: [CodeIgniter 4 redirect function not working](https://stackoverflow.com/questions/58707864/codeigniter-4-redirect-function-not-working) – steven7mwesigwa Jan 05 '23 at 10:25

2 Answers2

0

I have found the problem.

I have omitted return and additionally (for whoever lands here) if you are finding index.php in the uri and you are using mod_rewrite be sure that in app.php you have public $indexPage = '';

Combinu
  • 882
  • 2
  • 10
  • 31
0

Please use below format to redirect to the routes path

Routes.php

$routes->get('/login', 'Home::login');

Within Controller function Use Below format.

 return redirect()->route('login');
avariant
  • 2,234
  • 5
  • 25
  • 33
Omprakash
  • 1
  • 1