Last Updated: February 25, 2016
·
952
· laupifrpar

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

Source: http://kiwwito.com/symfony-2-route-redirection/

2 Responses
Add your response

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 ·