I’m trying to setup a simple redirect after a login.
The logging in part works but the redirect fails because it says the route doesn’t exist.
This is my routes file:
Route::any('/', array('uses' => '[email protected]')); Route::any('/manage', array('uses' => '[email protected]'));
And the route works fine if i go to http://example.com/manage .. the logo of laravel is there, and my other page is fine as well.
But when i do:
the page dies saying:
Route [/manage] not defined
Anybody have an idea?
You should use the route name when you are using
Redirect::route method and in this case you have to declare the route using a name, i.e.
Route::any('/manage', array('as' => 'manage', 'uses' => '[email protected]'));
as value is name of the
route, so, now you can use
return Redirect::route('manage'); // 'manage' is the name of the route to redirect
Or, alternatively, you can use
Redirect::to('url') method, i.e.
return Redirect::to('/manage'); // '/manage' is the url to redirect
This error “Route [manage] not defined” is because of the route name “manage” is not defined.
Route name and Route path are two different things.
And you’ve declared the route path as admin,
Route::any('manage', '[email protected]');
means that you are redirecting the flow to the route named “manage”.
To sort the error,
Define a route name “manage” as follows in an array defined below with ‘as’ => ‘route_name’.
Route::any('manage', [ 'as' => 'manage', 'uses' => '[email protected]' ]);
Please refer the link : https://laravel.com/docs/master/routing#named-routes
use return Redirect::intended(‘mannage’);