Welcome Guest, Not a member yet? Register   Sign In
Redirect issue
#2

(07-25-2019, 11:18 PM)SirTom Wrote: Hello,

I am working on a new project with Codeigniter 4.0 beta 4. I set the URL in the configuration file:

PHP Code:
public $baseURL 'http://localhost/mysite/'

If I now use a redirect, the URL will be redirected to an incorrect URL.

PHP Code:
return redirect()->to('/admin'); 

This call redirects to the following URL:

http://localhost/admin

I'd like someone to help me with this problem.

Thanks
Tom

I assume that in this function you should specify the full path to the page including the 1st segment "mysite":
Code:
return redirect()->to('mysite/admin');

and in order to be able to direct to the abbreviated url addresses you need to name each of your router in this way:
Code:
$routes->add('{locale}/admin', 'Users::profile', ['as' => 'my_route']);

and call the function:
Code:
redirect()->route('my_route');
or just
redirect('my_route');
I would change this world, but God doesn't give me the source.
Reply


Messages In This Thread
Redirect issue - by SirTom - 07-25-2019, 11:18 PM
RE: Redirect issue - by Digital_Wolf - 07-26-2019, 01:31 AM
RE: Redirect issue - by SirTom - 07-26-2019, 03:04 AM
RE: Redirect issue - by Digital_Wolf - 07-26-2019, 12:02 PM
RE: Redirect issue - by includebeer - 08-02-2019, 10:51 AM
RE: Redirect issue - by InsiteFX - 08-02-2019, 02:11 PM
RE: Redirect issue - by includebeer - 08-05-2019, 06:47 AM
RE: Redirect issue - by InsiteFX - 08-02-2019, 02:41 PM
RE: Redirect issue - by includebeer - 08-05-2019, 06:58 AM



Theme © iAndrew 2016 - Forum software by © MyBB