2012-03-02 131 views
0

Zend公司实施搜索引擎友好的或个性化网址我有一个简单的电子商务网络应用产品的URL,如:与路由器

http://www.example.com/product/view/product_id/15 

其中,“产品”是控制器和“观点”是产品的动作控制器

如何改变这个网址显示为:

http://www.example.com/product/view/product_name/iphone-4S-16-gb 

其中product_id“15”在产品表的主键product_name有不带连字符的值“iphone 4s 16 gb”

什么是最简单的方法让我做出这样的改变。 非常感谢您的帮助。 非常感谢。

回答

0
resources.router.routes.view-article.type = "Zend_Controller_Router_Route_Regex" 
resources.router.routes.view-article.route = "articles/(?!archive)([a-zA-Z\-]+)/(\d+)(?:/(.*))?" 
resources.router.routes.view-article.reverse = "articles/%s/%d/%s" 
resources.router.routes.view-article.defaults.module = "articles" 
resources.router.routes.view-article.defaults.controller = "view" 
resources.router.routes.view-article.defaults.action = "view-article" 
resources.router.routes.view-article.map.1 = topicSlug 
resources.router.routes.view-article.defaults.topicSlug = topicSlug 
resources.router.routes.view-article.map.2 = id 
resources.router.routes.view-article.defaults.id = 0 
resources.router.routes.view-article.map.3 = articleSlug 
resources.router.routes.view-article.defaults.articleSlug = articleSlug 

链接像http://example.com/articles/circus/616/4-marta-vse-za-ruletkami

http://example.com/products/category/product_id/product_name

编辑1

这是缺省路由器插件的设置。从我的博客模块显示为articles,但很容易更新商店。

部件 - http://example.com/是主机:) articles/circus/ =>模块和控制器mapeed。

resources.router.routes.view-article.map.1 = topicSlug是一个类别。为商店。

616/4-marta-vse-za-ruletkami ID和任何slu。。产品描述,例如'iphone-4S-16-gb '

默认值在配置中。

另一个例子/{maps2module}/{maps2topicSlug}/{maps2id}/{maps2articleSlug}

+0

也许有点解释? – 2012-03-02 11:20:47

+0

Sandro Meier,还好吗? – SMka 2012-03-02 11:34:13

+0

谢谢。对我而言足够了。我知道了。 :-D – 2012-03-02 12:09:33