My site have only one category (used cars) and many search options (faceted search), sorting and pagination. I use mod_rewrite (key/value -> key=value) to make URLs like this:
/used-cars/brand/ford/model/fiesta/fuel/diesel/sorting/price-asc/page/2
/used-cars/model/fiesta/variant/1.4-tdci/equipment/cd
…
Now, I need to add more categories and subcategories, and URLs should be LIKE this:
/vehicles
/vehicles/used-cars
/vehicles/used-cars/brand/ford/model/fiesta/fuel/diesel/sorting/price-asc/page/2
/vehicles/model/fiesta/variant/1.4-tdci/equipment/cd
…
As you can see, categories and subcategories are not key/value pairs, and may be just one category, or category/subcategory or category/subcategory-L1/subcategory-L2.
- First problem is how to delimit categories and key/value pairs (brand/ford…) to be able to parse it properly?
- Second problem is how to identify category (names are not unique)
I searched to see how other sites do this, and I found a lot of not-so-good solutions, and some that could be acceptable in the absence of better solutions.
Those deals with delimiting problem only:
/vehicles/used-cars/search/brand/ford/model/fiesta/fuel/diesel/sorting/price-asc/page/2
/vehicles[COLOR=“Red”]/[1]model/fiesta/variant/1.4-tdci/equipment/cd
And other that deals with both problems:
/vehicles/used-cars/cid16/brand/ford/model/fiesta/fuel/diesel/sorting/price-asc/page/2
/vehicles/used-cars-cid16/brand/ford/model/fiesta/fuel/diesel/sorting/price-asc/page/2
What is your suggestions?
Is it better way to store path (to the root) for each category and match it with category path from URL, or to use category_id in URL?
I hope that someone will understand me!
/COLOR ↩︎