2

I want have this urls:

example.com
example.com/category
example.com/category/name

My routes:

default_page:
    path:     /{name}
    defaults: { _controller: CatalogWebBundle:Default:index }
default_page:
    path:     /
    defaults: { _controller: CatalogWebBundle:Default:index }
default_page:
    path:     /{name}/{category}
    defaults: { _controller: CatalogWebBundle:Default:index }

Work properly only

example.com/category

What is wrong with my routes ?

Error is:

No route found for "GET /category/name"
No route found for "GET /"
3
  • 2
    I think it may be because you have them all set at default_page ? Or was that just for the example? Commented Nov 22, 2014 at 14:21
  • @ChadSikorra but this may be 1 page indexAction Commented Nov 22, 2014 at 14:22
  • 4
    Yes, but they still need different names for YAML otherwise some will be ignored and you will get unexpected results. Or maybe I'm not understanding something obvious? Time to grab my morning coffee haha. Commented Nov 22, 2014 at 14:43

2 Answers 2

3

braces are for variables. When you type .com/category it will go into your first route with "category" as value of the variable name

Sign up to request clarification or add additional context in comments.

3 Comments

Yes, I need pass variables by get example.com/category1/name1
unless you're in prod on a server and you don't have rewrite rules ?
I have all permisssion, it's my own dev server
2

make your internal name of the route unique and it should work properly.

default_page_X:
    path:     /{name}
    defaults: { _controller: CatalogWebBundle:Default:index }
default_page_Y:
    path:     /
    defaults: { _controller: CatalogWebBundle:Default:index }
default_page_Z:
    path:     /{name}/{category}
    defaults: { _controller: CatalogWebBundle:Default:index }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.