laravel MethodNotAllowedHttpException重定向到404

laravel MethodNotAllowedHttpException重定向到404,laravel,exception,handler,Laravel,Exception,Handler,我使用laravel 8试图编辑我的异常\handler.php 公共函数呈现($request,Throwable$exception) { if($MethodNotAllowedHttpException的异常实例){ 中止(404); } 返回父::render($request,$exception); } 但是当检查MethodNotAllowedHttpException的路由时,his给出的不是404而是500,一个可能的解决方案是为路由/web.php文件提供路由回退。尝试将

我使用laravel 8试图编辑我的异常\handler.php

公共函数呈现($request,Throwable$exception)
{
if($MethodNotAllowedHttpException的异常实例){
中止(404);
}
返回父::render($request,$exception);
}

但是当检查MethodNotAllowedHttpException的路由时,his给出的不是404而是500,一个可能的解决方案是为
路由/web.php
文件提供路由回退。尝试将以下内容添加到web路由的底部:

Route::fallback( function () {
    abort( 404 );
} );

这回答了你的问题吗?不,如果使用
\Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
而不是
MethodNotAllowedHttpException
,行代码重定向到500错误,则某些内容不起作用,同样的问题:/在firefox空白页的Chrome500错误中..我正试图找到解决方案,但目前运气不佳,这一个非常适合这个。谢谢