Last Updated: February 25, 2016
· laupifrpar

Symfony2: Redirection in the routing.yml only

Redirect from a route to another with a 301 status code is as easy as

    pattern: /
    defaults: { _controller: FrameworkBundle:Redirect:redirect, route: redirect_to, permanent: true }

    pattern: /redirect
    defaults: { _controller: Bundle:Controller:action }

That means, when you enter root you'll be redirected to /redirect


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 ·