Is the article slug unique? If so you could pretty much have any friendly url with the article slug trailing and just grab that?
URL Parsing/Dynamic Routing?
So, I'm working on a knowledge base, and one of the requirements is for the URLs to be as semantic and people-friendly as possible. There are Articles that can belong to one or more Article Categories (which can be nested), that can belong to one or more Product Categories.
It'd be super-easy to do using something like http://example.com/support/product/some-product/category/some-category/article/some-article, but we'd like to remove "product", "category", "article".
Some possible URL scenarios are:
- http://example.com/support/article-slug (if an article is accessed directly)
- http://example.com/support/product-category-slug
- http://example.com/support/product-category-slug/article-slug
- http://example.com/support/product-category-slug/article-category-slug
- http://example.com/support/product-category-slug/parent-article-category-slug/child-article-category-slug
- http://example.com/support/product-category-slug/parent-article-category-slug/child-article-category-slug/article-slug
... you can kinda see where this is going.
I've currently got it working, but it feels kinda ugly. I'm basically grabbing the url, and iterating through each scenario, checking all three tables to see what matches where. It definitely works, but I just wanted to see if anyone's done something similar or has any other suggestions.
Thanks!
Please or to participate in this conversation.