Symfony2: Redirection in the routing.yml only
Redirect from a route to another with a 301 status code is as easy as
route:
pattern: /
defaults: { _controller: FrameworkBundle:Redirect:redirect, route: redirect_to, permanent: true }
redirect_to:
pattern: /redirect
defaults: { _controller: Bundle:Controller:action }
That means, when you enter root you'll be redirected to /redirect
Written by Pierre-Louis LAUNAY
Related protips
2 Responses
do you mean yml?
over 1 year ago
·
Yes, sorry I wrote wrong title. But you can write same thing in XML.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Symfony2
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#