I know this is probably trivial, but I couldn't find anything on the web or in the Symfony2 reference.
How do I redirect one route to another from routing.yml (with 301 status code)?
I'm looking for something like this:
SomeRoute:
pattern: /someroute
defaults: { _controller: SomeBundle:Controller:action }
AnotherRoute:
pattern: /anotherroute
defaults: { _redirect: {route: SomeRoute, status: 301} }
I could create a controller, but it seems overkill, since I don't have any parameters (and it would be overkill even so, if they are to be passed as they are).
SomeRoute: pattern: /someroute defaults: _controller: SomeBundle:Controller:action AnotherRoute: pattern: /anotherroute defaults: _controller: FrameworkBundle:Redirect:redirect route: SomeRoute permanent: true # this is for 301 page: 5 # you can pass additional attributes
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