Welcome Guest, Not a member yet? Register   Sign In
what happen is error with redirect to codeigniter 4.3.3
#2

(This post was last modified: 04-19-2023, 02:45 AM by Muzikant.)

Hi. Check if you have correctly set destination route auth/home in app/Config/Routes.php. It could be something like this:

PHP Code:
$routes->get('auth/home''Auth::home'); 

You could also check if you have correct variables $baseURL and $indexPage in app/Config/App (or in .env file if you are using it), because redirect()->to() is based on these values.



If it does not work, then try only redirection on a fresh CodeIgniter's installation.

app/Config/App.php
PHP Code:
// ...
// change these variables
    public string $baseURL 'http://localhost:8080/'// change if you are not using "php spark serve" or if it started on a different port
    public string $indexPage ''// removing index.php proved to me in all cases
// ... 

app/Config/Routes.php
PHP Code:
// ...
// add these routes
$routes->get('from''Home::from');
$routes->get('to''Home::to');
//... 

app/Controller/Home.php
PHP Code:
// ...
// add these methods
    public function from()
    {
        return redirect()->to('to');
    }
    public function to()
    {
        echo 'Successfully redirected to home/to.';
    }
// ... 

Access this URL in a web browser (based on $baseURL): http://localhost:8080/from and watch if it is working. If it will work, then the problem is somewhere in your code or settings.
Reply


Messages In This Thread
RE: what happen is error with redirect to codeigniter 4.3.3 - by Muzikant - 04-19-2023, 02:35 AM



Theme © iAndrew 2016 - Forum software by © MyBB