我是Laravel的初学者。我正在使用udemy视频学习laravel。我想在登录后更改默认重定向。 我将路线更改为
[aeiouAEIOU][bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ]([aeiouAEIOU])
和Route::group(['prefix' => 'admin', 'middleware' => 'auth'],function (){
Route::get('/home', 'HomeController@index')->name('home');
});
Http/Middleware/RedirectIfAuthenticated.php
,但是当我再次登录时,我重定向到 public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
return redirect('/admin/home');
}
return $next($request);
}
而不是/home
。
我清除了缓存,但它再次无法正常工作。
答案 0 :(得分:4)
如果您只希望重定向是未经授权的,则只需写
Route::group(['prefix' => 'admin', 'middleware' => 'guest'],function (){
Route::get('/home', 'HomeController@index')->name('home');
});
,如果您要在登录后重定向到“ admin / home”,请在
中进行桅杆更改LoginController
protected $redirectTo = '/admin/home';