gpt4 book ai didi

Laravel 5 - 抱歉,找不到您要查找的页面

转载 作者:行者123 更新时间:2023-12-02 10:32:40 29 4
gpt4 key购买 nike

我试图在登录后将 Laravel 页面重定向到另一个主页,但它每次都会将我重定向到 home 。我所做的是:我将 protected $redirectTo = 的值从 home 更改为 protected $redirectTo = 'S1CheckUserTables';。< br/>我还在 web.php 中定义了我的路由,如下所示(我相信我将使用命名路由):

Route::get('/S1CheckUserTables', ['as'=>'S1CheckUserTables', 'uses'=>'S1CheckUserTablesController@index']);

我还尝试使用以下语法来解决该问题,但也不起作用:

Route::get('S1CheckUserTables', 'S1CheckUserTablesController@index')->name('S1CheckUserTables');

您能告诉我什么可以解决我的问题吗?预先非常感谢您。

最佳答案

登录后 Laravel 的默认重定向是转到 LoginController 中设置的/home:

use AuthenticatesUsers;

/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = '/home';

并且有默认中间件RedirectIfAuthenticated

class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
return redirect('/home');
}

return $next($request);
}
}

以及 app/Http/Controllers/Auth/RegisterController.php

class RegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/

use RegistersUsers;

/**
* Where to redirect users after login / registration.
*
* @var string
*/
protected $redirectTo = '/home';

因此,这就是您需要进行更改才能按照自己的方式工作的地方...

关于Laravel 5 - 抱歉,找不到您要查找的页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41411645/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com