php - Symfony 2 Routing - Prefix for optional parameters -


problem solve

i have url prefixed parameters. need seo reasons, can't create complete slug foo-5.

the url looks like this: /foo-{foo_id}/bar-{bar_id} , want second parameter bar optional. url /foo-{foo_id} still valid.

example

my route defined this:

@route("/foo-{foo_id}/bar-{bar_id}, requirements={  "foo": "\d+", "bar": "\d+" }) 

as can see, need /bar- valid route. can define second route without bar definition. have name etc.

@route("/foo-{foo_id}/bar-{bar_id}, requirements={"foor": "\d+", "bar": "\d+"}, name="route_foo_bar") @route("/foo-{foo_id}, requirements={ "foor": "\d+"},name="route_foo_bar") 

is possible define requirements in 1 route /bar-{bar_id} optional?


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -