Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
How can I create duplicate routes?
I want to have SEO and user friendly routing like:
/{product.slug}
/{category.slug}
But how does Symfony know which one to render? It now defaults to the last definition.
/p/{product.slug}
/c/{category.slug}
/{product_or_category}
edit
You can create you route with two variables:
/{type}/{slug}
type would be productor category
type
product
category
Or, if you want only one variable, you can adapt your function depending on the value passed by URL.
Add a comment
Required, but never shown
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.
Explore related questions
See similar questions with these tags.
/p/{product.slug}and/c/{category.slug}is user friendly enough, isn't?/{product_or_category}and then forward the request to ProductController or (if product is not found) CategoryController/{product_or_category}isn't a good structure either: what if you have a category with the same name of a product? what would you render?editpart is what you need.