Zend Framework 分层路由
我正在尝试使用 Zend Framework 按以下方式设置路由。
- http://localhost
- http://本地主机/类别/
- http://localhost/category/product
- http://localhost/category/subcategory/product
- http://本地主机/类别/子类别/子子类别/产品
- http://localhost/category/subcategory/subsubcategory/subsubsubcategory/product
- http://localhost/category/subcategory/subsubcategory/subsubsubcategory/subsubsubsubcategory/product
我已经尝试过正常路由,但到目前为止它只让我工作,并且无法正常工作。
resources.router.routes.product.route = ":categoryAlias/:productAlias/*"
resources.router.routes.product.type = "Zend_Controller_Router_Route"
resources.router.routes.product.defaults.controller = 索引
resources.router.routes.product.defaults.action = 目录
resources.router.routes.category.route = ":categoryAlias/*"
resources.router.routes.category.type = "Zend_Controller_Router_Route"
resources.router.routes.category.defaults.controller = 索引
resources.router.routes.category.defaults.action = 目录
我可以访问:
但这就是我所了解到的。关于如何更好地解决这个问题有什么想法或建议吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于技术部分,这个类似的问题会对您有所帮助。
现在让我们谈谈一些 SEO 问题:
如果您决定更改产品的层次结构,会发生什么?它的 URI 会发生变化,您将不得不处理这样一个事实:人们将添加书签或共享“旧”url,现在导致 404。更不用说页面排名的影响了。您可以通过仍然管理旧 URL 并重定向到新 URL 来避免这些问题,但这是您从一开始就希望避免的一些工作。
我建议使用短的永久网址,并在面包屑中显示层次结构
似乎对于谷歌来说,具有短路径的页面比具有短路径的页面更“重要”有一条很深的路。这就是为什么许多网站将他们眼中最重要的内容放在根本没有路径的情况下(my.site.com/awesome-printer),而其余的则放在短路径中。更不用说这种形式对于人类来说也确实更具可读性。
另请记住,从主页最多点击 3-5 次即可访问任何页面,以便有机会被机器人索引。而对于人类来说,这也确实很烦人。
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
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.