close

[Solved] CodeIgniter 4 redirect function not working

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error CodeIgniter 4 redirect function not working in php. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How CodeIgniter 4 redirect function not working Error Occurs?

Today I get the following error CodeIgniter 4 redirect function not working in php.

How To Solve CodeIgniter 4 redirect function not working Error ?

  1. How To Solve CodeIgniter 4 redirect function not working Error ?

    To Solve CodeIgniter 4 redirect function not working Error I use this and it works
    return redirect()->to(site_url());

  2. CodeIgniter 4 redirect function not working

    To Solve CodeIgniter 4 redirect function not working Error I use this and it works
    return redirect()->to(site_url());

Solution 1

I use this and it works

return redirect()->to(site_url());

Solution 2

In codeigniter 4 redirect()->to() returns a RedirectResponse object, which you need to return from your controller to do the redirect.

for ex.

class Home extends BaseController {
    public function index() {
        return redirect()->to('https://example.com');
    }
}

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read

Leave a Comment