Getting HTTP 404 when redirecting but reloading works. |
Using CodeIgniter 4.5.3, after doing user identification (you know, creating a session variable and updating the database to register the login) I do a redirection to the index page this way:
PHP Code: return redirect ()->to ('', 307); Accessing the index page directly (by putting the URL) doesn't fail. Doing other redirections (for example, when the index page detects the user isn't identified it redirects to the login page using same code) works without any problem. Anybody knows any reason for this behavior?
An empty string for the URL is probably invalid.
Try to specify "/" or name for the Route. It needs to be configured with the "as" parameter in Routes.php
The most common cause of a 404 error is that the route does not exist.
1. Set development mode. https://codeigniter.com/user_guide/insta...pment-mode and see the error message. 2. Check your routes. https://codeigniter.com/user_guide/incom...ark-routes
(07-15-2024, 03:26 PM)kenjis Wrote: The most common cause of a 404 error is that the route does not exist. It's in development mode yet. No error message except the HTTP 404 error. I'm not using Spark, I'm using Apache. Routes checked; they're correct as the web works. It only "fails" when redirecting after log-in, any other way accessing the index (writing the URL directly, using a link or reloading when receiving the 404 error) work as expected. The redirection is done correctly as the browser shows the correct URL. The thing that puzzles me is why it loads when I reload. Maybe I'm not explaining (or understanding) it properly.
Spark provides useful commands for development. If you use it, it helps a lot.
Code: $ php spark routes When I see CI4's 404 message in development mode, I see a message like this. Code: 404
(07-16-2024, 02:16 PM)kenjis Wrote:(07-15-2024, 10:46 AM)Ñuño Martínez Wrote: Because it is not a permanent redirection. (07-16-2024, 02:14 PM)kenjis Wrote: Spark provides useful commands for development. If you use it, it helps a lot.But it is a web application, not a console application. I need a webserver, hence the use of Apache.
I meant, "Spark provides useful commands for web app development and checking app configuration on product environments."
Can't you show the output of `php spark routes` and the exact error message when 404 like the following?
Quote:404 |
Welcome Guest, Not a member yet? Register Sign In |