Reputation: 478
So I have a route:
Route::get('dashboard', 'Dashboard\DashboardController@index');
And when I try to open this route a trailing slash is added and I am being redirected to a 404 error. this: /dashboard becomes this /dashboard/
And the strangest thing is that is happening with ONLY the dashboard route, All other routes are working just fine.
Route::get('dashboard/users', 'Dashboard\UsersController@index');
Route::get('dashboard/users/create', 'Dashboard\UsersController@create');
Route::post('dashboard/users/create', 'Dashboard\UsersController@store');
Route::get('dashboard/users/edit/{id}', 'Dashboard\UsersController@edit');
Route::post('dashboard/users/edit/{id}', 'Dashboard\UsersController@update');
Route::get('dashboard/users/delete/{id}', 'Dashboard\UsersController@destroy');
all these and all other routes work fine
any suggestion is welcome
Upvotes: 1
Views: 459
Reputation: 478
The solution was obvious. I just missed it.
I had a folder under the public folder with the same name as my route and the .htaccess clearly states:
# Redirect Trailing Slashes If Not A Folder...
So if anyone else comes across this issue just check that you dont have a folder under the public that has the same name as a route.
Upvotes: 1
Reputation: 3569
It is intentional.
In their .htaccess file, you can read the following snippet:
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
Wich does the redirection (Line 8 in the current version).
If you dont want it to redirect, just comment those lines.
Upvotes: 1