1

I have a simple redirectt in my routing.yml file:

products_in_categories:
    path: /{slug}
    defaults: { _controller: MpShopBundle:Category:show }

redirect_category:
    path: /112-redirect-this
    defaults:
        _controller: MpShopBundle:Category:show
        route: products_in_categories
        slug: to-this
        permanent: true

So when I go to localhost/web/app_dev.php/112-redirect-this it should do a 301 redirect and change the url... It load the pages successfully, but the url is not changed. It shows:

localhost/web/app_dev.php/112-redirect-this when it should show: localhost/web/app_dev.php/to-this

Am I doing something wrong?

Dominykas55
  • 1,231
  • 14
  • 45
  • Possible duplicate of [Redirect (301) one route to another from routing.yml in Symfony2](http://stackoverflow.com/questions/8529038/redirect-301-one-route-to-another-from-routing-yml-in-symfony2) – hchr Aug 12 '16 at 07:02

1 Answers1

2

According to the Symfony documentation your redirecting route should point to the FrameworkBundle:Redirect:redirect action:

redirect_category:
    path: /112-redirect-this
    defaults:
        _controller: FrameworkBundle:Redirect:redirect
        route: products_in_categories
        slug: to-this
        permanent: true

It's described here: http://symfony.com/doc/current/routing/redirect_in_config.html#redirecting-using-a-route

hchr
  • 317
  • 1
  • 12
Jakub Krawczyk
  • 950
  • 8
  • 16