Problems when removing routes

Cleaning out in your routes can sometimes give problems. One such problem is a redirect loop, where the error 500 page itself was bugged.

Let us say that we have the following route, which have been taken from the Laravel documentation:

Route::get('user/profile', array('as' => 'profile', function()

The route above is a named route, with profile as its name. The name can be used when we later will be getting the URL for the route.

In order to get the URL, we will be using the following helper function:

$url = URL::route('profile');

This is all well and fine, as long as a route with that name exists. If we try to remove the above route while calling the URL::route function with the deleted route name as a parameter, an exception will be thrown.

The solution will be to remove all attempts to generate the URL for the deleted route from your site.

In our case with the redirect loop, the error 500 page contained an attempt to get the URL of a recently deleted route. This resulted in the error 500 page itself failing and Laravel trying to go to that same page as a consequence.'

Bjarne Bonde