Description
Just a simple one. I tried creating the following route:
Route::get('hello', function()
{
return View::make('hello');
});
But this route is then only accessible at example.com/hello
and not example.com/hello/
, which throws a NotFoundHttpException
. Obviously, creating the route for hello/
then means the route is no longer accessible at 'example.com/hello'. This is exactly what is supposed to happen, since the route didn't match, but it might not be what is expected to happen.
Type any URL on the Laravel 4 documentation site, absent-mindedly include a trailing slash, and you won't find the page.
This could be a feature when creating RESTful APIs (when a URI resource with a trailing slash is considered different from one without), but for standard navigation it could be a common query; especially since "Pretty URLs" commonly append a trailing slash for neatness.
To avoid this, users could simply define routes twice, in my case, for both hello
and hello/
.
Route::get('hello', function()
{
return View::make('hello');
});
Route::get('hello/', function()
{
return Redirect::to('hello')
});
However, I'm pretty sure doing this for every route for which a trailing slash could be a possibility would be quite annoying. On the other hand, you also wouldn't want to assume and use the .htaccess
file to automatically add the slash automatically to all routes.
tl;dr Not sure if bug or feature, and merely a 'gotcha' for new users.