I found several approaches to get rid of the annoying 404-error when you open a route with a trailing-slash:
www.symfonysite.com/route
>> ok
www.symfonysite.com/route/
>> Error: 404-not found
The easiest solution is to add a RewriteRule to your .htaccess:
1 |
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L] |
Now all requests with trailing-slash are redirected to the one without trailing-slash.
Notice that this only works as long as you do not have any routes which want require a trailing slash, because this would lead to an redirect loop:
1 |
pattern: / |