Welcome Guest, Not a member yet? Register   Sign In
Redirect and baseURL with subdir not working

Just checking if I am doing something wrong.
Currently, https://github.com/codeigniter4/CodeIgni...ssues/2445 is the only thing that keeps me from adopting CI4 completely as I need to hack a system file to get it to work. I have downloaded the latest develop from github but still no go.

So, my question is - is it me doing something wrong?

I have baseURL = 'https://backend.tangixdev.se/client/'
I have updated public/.htaccess and changed the RewriteBase:
RewriteBase /client/

Routes are setup:
$routes->add('home', 'Home::index');
$routes->add('home/test', 'Home::test');
$routes->add('home/index', 'Home::index');

Now trying to do redirects from https://backend.tangixdev.se/client/home/test and it doesn't work:
return $this->response->redirect('/home/index'); // redirects to https://backend.tangixdev.se/home/index
return $this->response->redirect('home/index'); // redirects to https://backend.tangixdev.se/client/home/home/index

The only thing that works for me is:
return $this->response->redirect(site_url('home/index'));

Is the last snippet the correct way to do a redirect? But this seems to override the routing logic?

According to the documentation we should do something like this:
return $this->response->redirect()->to('/home/index');

But this gives error: Too few arguments to function CodeIgniter\HTTP\Response::redirect(), 0 passed in

If anyone could point me in the right direction that would be much appreciated. As indicated in the issue reference, my only way forward is using site_url() or hack the framework file.
Too few arguments to function Code

Messages In This Thread
Redirect and baseURL with subdir not working - by tgix - 01-13-2020, 11:57 PM

Theme © iAndrew 2016 - Forum software by © MyBB