Redirect - route cannot be found while reverse-routing. |
Hi,
what does this message mean? in my routes there is a route The call of redirect($route) is not working but the call of $this->response->redirect('/' . $route) is working. What is the correct use of the redirect function?
(09-15-2022, 07:08 PM)kenjis Wrote: See https://codeigniter4.github.io/CodeIgnit...l#redirect in my controller method this is not working: PHP Code: return redirect()->to('/' . $route);
Check your real Response headers to see what is different.
(09-16-2022, 02:07 AM)kenjis Wrote: Check your real Response headers to see what is different. I can't get it to work. I make a POST-Request to the same page where the form is located and if form validation is successful i want to redirect to another page. By using $this->response->redirect i get a 303 statuscode and in the header there is an entry location with the new page If i use request()->to the location in the header is the same page
I'd omit '/' in return redirect()->to('/' . $route);
Can you just not do return redirect()->to($route) ? CodeIgniter Wizard (CRUD code generator for Mac) instantly scaffolds Bootstrap-based web applications with an administrative interface (admin templates include Bootstrap5)
(09-16-2022, 08:59 AM)gosocial2 Wrote: I'd omit '/' in return redirect()->to('/' . $route); This is also not working. I don't know what i am doing wrong, but the other call is working with the $this->response... (09-16-2022, 02:07 AM)kenjis Wrote: Check your real Response headers to see what is different. The response header with $this->response->redirect has a location property but with return redirect()->to() the response header has no location property Ok, i think i know what i am doing wrong. I made the redirect call in a function which i call in another function and in every function i have to return the redirect object in order to get it to work. Previously i returned the redirect object only in one function
Yes, it is a common mistake.
Quote:Important |
Welcome Guest, Not a member yet? Register Sign In |