Cant use addRedirect() - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Cant use addRedirect() (/showthread.php?tid=77098) |
Cant use addRedirect() - BlackBanana - 07-18-2020 In the docs in this part https://codeigniter.com/user_guide/incoming/routing.html#redirecting-routes See this code in Routes.php $routes->get('/users/profile', 'Users::profile', ['as' => 'profile']); $routes->get('/users/about', 'Users::about', ['as' => 'about']); $routes->addRedirect('/users/profile', '/users/about'); Now i should be redirected from {users/profile} when i visit it to {users/about} , instead i have this error key() expects parameter 1 to be array, string given i have the Users controller made and inside it profiles and about method , so where is the problem , why isnt it redirecting ? This is Users controller <?php namespace App\Controllers; use CodeIgniter\Controller; class Users extends Controller { public function profile() { echo 'Profile method in User controller'; } public function about() { echo 'About method in User controller'; } } RE: Cant use addRedirect() - jreklund - 07-19-2020 You made an alias and you aren't using it. PHP Code: $routes->addRedirect('users/profile', 'about'); May be like this, haven't tried it: PHP Code: $routes->addRedirect('profile', 'about'); |