Reputation: 10187
Working on Laravel 5.2 app, My problem with routes I've defined.
1. Redirect to home
Route::get('/', ['as' => '/','uses' => 'HomeController@index']);
2. Redirect to user profile i.e "www.mydomain.com/samrow"
Route::get('/{username?}', ['as' => '/','uses' => 'HomeController@profile']);
3. Not Redirect to dashboard, its redirect to profile action
Route::get('/dashboard', ['as' => '/dashboard','uses' => 'HomeController@dashboard']);
Thanks in advance!
Upvotes: 1
Views: 33
Reputation: 3467
Laravel uses the first route that matches the request, so the order in which you define them is important.
Route::get('/dashboard', ['as' => '/dashboard','uses' => 'HomeController@dashboard']);
Route::get('/{username?}', ['as' => '/','uses' => 'HomeController@profile']);
// Catch all should always be last
Route::get('/', ['as' => '/','uses' => 'HomeController@index']);
Upvotes: 1