acme_admin_dashboard:
pattern: /{_locale}/admin
defaults: { _controller: AcmeBundle:Admin:dashboard }
I want this route to be accessible at /en/admin
and /en/admin/
. How would I achieve this?
I like @Kuchengeschmack's answer (https://stackoverflow.com/a/11078348/593957) because it doesn't trigger external redirects.
Here's a yaml version:
acme_admin_dashboard:
pattern: /{_locale}/admin{trailingSlash}
defaults: { _controller: AcmeBundle:Admin:dashboard, trailingSlash : "/" }
requirements: { trailingSlash : "[/]{0,1}" }
Just type :
/**
* @Route("/route/of/some/page/")
*/
so
www.example.com/route/of/some/page
and
www.example.com/route/of/some/page/
are accepted...
I found a solution to add a trailing slash to a route.
means both link are working www.example.com/route/of/some/page
and www.example.com/route/of/some/page/
. You can do is this way:
if you route looks like
/**
* @Route("/route/of/some/page")
*/
public function pageAction() {
change ist to
/**
* @Route("/route/of/some/page{trailingSlash}", requirements={"trailingSlash" = "[/]{0,1}"}, defaults={"trailingSlash" = "/"})
*/
public function pageAction() {
You could also simply use rewrite rule in the .htaccess file:
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]
http://symfony-blog.driebit.nl/2010/07/url-routes-with-or-without-a-trailing-slash/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With