2017-01-04 18 views
0

末尾には見られない私は、次のルートがありますsymfonyの2/3ルートスラッシュ

product_category: 
    path: /{grandFatherSlug}/{fatherSlug}/{childSlug} 
    defaults: { _controller: ProductCategory:productCategoryPage, fatherSlug: "", childSlug: ""} 
    options: 

を私はルートのこの種のためにSEOの推奨の、最後のスラッシュで終わって欲しいです。 しかし、私はそれを動作させることはできません。私はでstr_replaceを呼び出すために作るもの、

product_category: 
    path: /{grandFatherSlug}/{fatherSlug}/{childSlug}/ 
    defaults: { _controller: ProductCategory:productCategoryPage, fatherSlug: "", childSlug: ""} 
    requirements: 
    childSlug: .+ 
    fatherSlug: .+ 
    grandFatherSlug: .+ 

が、私は追加の末尾のスラッシュとの最後のパラメータを取得する:私は試してみました:

product_category: 
    path: /{grandFatherSlug}/{fatherSlug}/{childSlug}/ 
    defaults: { _controller: ProductCategory:productCategoryPage, fatherSlug: "", childSlug: ""} 
    options: 

しかし、私はルートが見つからない例外を取得し、とコントローラーを取り外してください。

この動作を達成するための簡単な解決法はありますか?

おかげ

+2

http://symfony.com/doc/current/routing/redirect_trailing_slash.html –

答えて

0

は、あなたの正規表現で/を避けるためにしようとしたことがありますか?

product_category: 
    path: /{grandFatherSlug}/{fatherSlug}/{childSlug}/ 
    defaults: { _controller: ProductCategory:productCategoryPage, fatherSlug: "", childSlug: ""} 
    requirements: 
    childSlug: [.+^\/] 
    fatherSlug: .+ 
    grandFatherSlug: .+