0
votes

I'm trying to set up routing in the following way using Zend Framework.

I've tried with normal routing but it only got me so far, and it's not working correctly.

resources.router.routes.product.route = ":categoryAlias/:productAlias/*"

resources.router.routes.product.type = "Zend_Controller_Router_Route"

resources.router.routes.product.defaults.controller = index

resources.router.routes.product.defaults.action = catalog

resources.router.routes.category.route = ":categoryAlias/*"

resources.router.routes.category.type = "Zend_Controller_Router_Route"

resources.router.routes.category.defaults.controller = index

resources.router.routes.category.defaults.action = catalog

I can get to:

But that's as far as I've gotten to. Any ideas or tips on how to approach this in a better way?

1
first of all (but it won't solve the hierarchy problem) your second route has the same name 'index' as the first. Each route needs is own name !Frederik Eychenié
For the hierarchy problem, is there a maximum depth in the category tree ?Frederik Eychenié
@FrederikEychenié, no, it was just an example, it can go further than that. Categories are based on MySQL nested set model.user554992
If I give them different names I get application error.user554992
That's because your second route matches your url first. Your have to keep in mind that routes are matched "the last one first". If it worked with the same name it's just because the second route wasn't even loaded in the router, as a route with the same name was already definedFrederik Eychenié

1 Answers

1
votes

For the technical part, this similar question will help you.

Now lets talk about some SEO concerns :

What happens if you decide to change the hierarchy for a product ? It's URI would change, and you will have to handle the fact that people will have bookmarked or shared the 'old' url, leading now to a 404. Not to mention page rank implications. You can avoid these issues by still managing the old URL and redirecting to the new url, but that's some work you prefer to avoid from the start.

I would suggest to use short permanent urls, and show the hierarchy in breadcrumbs

  • /product/9384-awesome-printer
  • /category/374-laser-printers

It seems that for google, a page having a short path has more 'importance' than one with a deep path. That's why a lot of sites put what's most important in their eyes with no path at all (my.site.com/awesome-printer), and the rest in short paths. Not to mention that this form is really more readable for humans too.

Also keep in mind that any page should be accessible in maximum 3-5 clicks from the home page, in order to have chances to be indexed by bots. And for humans, it's really annoying too.