2016-05-07 6 views

答えて

1

rfc2616 10.4.6 405 Method Not Allowed

の表示を編集する修正する必要があるときにホームページにユーザーをリダイレクトすることが可能ですあなたの.env

APP_ENV=production 
APP_DEBUG=false 

と作成

resources/views/errors/405.blade.php

405コードが発生するたびにそのファイルがレンダリングされますが、リダイレクトは可能ではないと思われますが、リダイレクトされるユーザーのために405エラーテンプレートにjavascriptを追加できます。

setTimeout(function(){ window.location.href='/'; },10000); 
1

ここでは、レンダリング方法を見つけるでしょう、あなたのapp/Exception/Handler.php

を開きます。

では、方法は、あなたのreturn statement前にこの行を追加レンダリング:

If($e instance of MethodNotAllowedHttpException) 
return redirect('/'); 
0

あなたはオープンアプリ/例外/ Handler.php 変更が法

public function render($request, Exception $e) 
{ 
    if ($e instanceof ModelNotFoundException) 
    { 
     return \Redirect::to('/'); 
    } 
    return parent::render($request, $e); 
} 
0

あなたは意志をレンダリングexceptionHandlerの

を使用することができますMethodNotAllowedExceptionを正常にキャッチする前に、正しい名前空間を最初にインポートする必要があります。

use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; 

ソース:Laravel 5 - How do I handle MethodNotAllowedHttpException

関連する問題