It is important to remove trailing slashed from applications made with laravel and it is bad for SEO as Google will index your page twice, once with slash and once without it. The correct behaviour is to create 301 for ever page with trailing slash to avoid content duplication in search results.
Here is the source: https://developers.google.com/search/blog/2010/04/to-slash-or-not-to-slash
An easy way to check if your app is behaving properly is to create a test route in routes/web.php
like this:
Route::get('/foobar', function () {
return 'simple test';
});
Then visit this endpoint with trailing slash yourapp.test/foobar/
If "simple test" was displayed and trailing slash did not dissapear from your url in the browser window then Google will not be happy about it and you need to fix it.
Via Composer
composer require aurawindsurfing/slashremovemiddleware
This package will auto register itself in Laravel 6 and higher.
Now repeat the same test.
You should be redirected to the same url but without trailing slash yourapp.test/foobar
and see the same text.
Now Google will only index every page once.
Please see the changelog for more information on what has changed recently.
composer test
Please see contributing.md for details and a todolist.
If you discover any security related issues, please email author email instead of using the issue tracker.
license. Please see the license file for more information.