2016-08-12 12 views
1

URL変更していない:私はlocalhost/web/app_dev.php/112-redirect-thisに行くときSymfony2の301リダイレクトは私のrouting.ymlファイルに簡単なredirectt持っ

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 

だから、それは301リダイレクトを行うと、URLを変更する必要がありますが...それはロードページは正常に表示されますが、URLは変更されません。それは示しています

localhost/web/app_dev.php/112-redirect-thisは、それが表示されるはずですとき: localhost/web/app_dev.php/to-this

私が何か間違ったことをやっていますか?

+0

が重複する可能性をsymfony2で](http://stackoverflow.com/questions/8529038/redirect-301-one-route-to-another-from-routing-yml-in-symfony2) – hchr

答えて

2

symfonyのドキュメントによると、あなたのリダイレクトルートがFrameworkBundle:Redirect:redirectアクションを指している必要があります:

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

それは、ここで説明しています:[リダイレクト(301)のrouting.ymlから別のルートのhttp://symfony.com/doc/current/routing/redirect_in_config.html#redirecting-using-a-route

+0

ああ私の神と私はあなたのことを書く必要があると思ったコントローラーの位置は...ありがとう! – Dominykas55

関連する問題