URL routes with or without a trailing slash
Say you have defined a route like so:
news:
url: /news
param: { module: news, action: index }
This will be matched by http://something.something/news, but not by http://something.something/news/
You might add an additional route with a trailing slash, but you could also simply use this rewrite rule in the .htaccess file:
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]
One Comment
→
I use the following in symfony 2:
route_name:
pattern: /:controller{slash}
defaults: { _controller: bundle:controller:action }
requirements:
slash : ‘\/?’
Hope this is useful. And yes, it creates an unused parameter $slash.