定制 404 Laravel

Aki*_*tel 2 php http-status-code-404 laravel laravel-authentication

如果我们只是404.blade.php在其中创建一个页面resources/views/error就可以正常工作,但是Auth()在 404 页面上不起作用,要解决这个问题,如果我们遵循 stackoverflow 上提供的解决方案,Laravel 身份验证错误将停止工作。我使用以下解决方案来完成这项工作。

Kam*_*aul 5

创建自定义视图

resources/views/errors/404.blade.php

在路由.php中

Route::any('{catchall}', 'PageController@notfound')->where('catchall', '.*');
Run Code Online (Sandbox Code Playgroud)

创建PageController并添加此函数

public function notfound() 
{ 
    return view('errors.404'); 
}

Run Code Online (Sandbox Code Playgroud)