为什么Laravel "remembering"这条被删除的路由?

Why is Laravel "remembering" this deleted route?

我有一个 route > controller > view 组合,它在 Laravel 中显示了一个登录表单。
表单不再需要,所以我干脆删除了如下所示的代码。

// file: routes.php
Route::get('/account/sign-in', array(
    'as'    => 'account-sign-in',
    'uses'  => 'AccountController@getSignIn'
));

.

// file: AccountController.php
 public function getSignIn() {
   return View::make('account.signin');
}

.

// file: /app/views/account/signin.blade.php

如果我在浏览器地址栏中输入旧的 URL: /account/sign-in 我会得到 Laravels "whoops" 屏幕:

Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException

* @throws \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
     */
    protected function methodNotAllowed(array $others)
    {
        throw new MethodNotAllowedHttpException($others);
    }

如何防止请求旧路由时抛出此异常?


相关信息

POST account/change-password  
GET|HEAD account/change-password
account/sign-out
POST account/forgot-password 
POST account/create  
 POST account/sign-in   
GET|HEAD account/forgot-password

我已经尝试过

什么都不记得了。

它向您显示 404 错误页面,因为路由不存在。您可以通过异常看到:MethodNotAllowedHttpException

原因是你有Route::post('account/sign-in').

如果您不想为该路由显示 404 错误页面 - 您需要保留 Route::get() - 然后从控制器重定向(使用 return Redirect::*)到另一个页面 - 所以用户会自动重定向。

或者您需要将 Route::post('account/sign-in') 更改为其他内容。