Zend Router 各种 URL
我想用 ZF 路由器实现类似的目标。 ('controller' => 'products', 'action' => 'index'
)
//Show product details
'http://mydomain.com/en/products/category-1/subcategory-3/product-name.htm'
//List products in subcategory-3
'http://mydomain.com/en/products/category-1/subcategory-3.htm'
//List products in category-1
'http://mydomain.com/en/products/category-1.htm'
//List products in all categories
'http://mydomain.com/en/products.htm'
我是否必须将每种可能性指定为单独的路线?或者有更好的解决方案吗? (使用Route_Regex
?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过使用空默认值来获得近似的路由,如下所示:
该路由不会处理
/en/products.htm
上的.htm
扩展名,并且类别/子类别/产品的值可能会附加一个.htm
。使用一点 .htaccessRewriteRule
魔法从请求中剥离.htm
可能比使用基本的 Zend_Router 更容易处理)另一种方法是使用自定义或正则表达式路由
You can get a route to approximate that by having empty defaults like so:
That route isn't going to handle your
.htm
extension on/en/products.htm
, and the category/subcategory/product might have a.htm
appended to their values. It is probably easier to handle stripping the.htm
from the request with a little .htaccessRewriteRule
magic rather than working around it with basic Zend_Router)The alternative would be to use a Custom or Regular Expression route