Zend Framework1.9伪静态设置

ZF默认路由是www.xxx.com/controller/action/parame1name/parame1value/parame2name/param2value 这种格式的。

这种路径格式的SEO效果虽然好于.php,但目录结构太深,还是会对搜索结果造成不利的影响。

我们可以通过自己的设定进行改变,ZF1.9把路由设定的方式大大简化了。我做了两个实际用到的例子:

修改application.ini,在[production]段中增加如下资源:

;===路由配置===
resources.router.routes.index.type = "Zend_Controller_Router_Route"
resources.router.routes.index.route = "index.html"
resources.router.routes.index.defaults.controller = "index"
resources.router.routes.index.defaults.action = "index"

 

resources.router.routes.listarticles.type = "Zend_Controller_Router_Route_Regex"
resources.router.routes.listarticles.route = "listarticles/(/d+)-(/d+)-(/w.+)/.html"
resources.router.routes.listarticles.defaults.controller = "index"
resources.router.routes.listarticles.defaults.action = "listarticles"
resources.router.routes.listarticles.map.1 = "itemId";

resources.router.routes.listarticles.map.1 = "pageNum";
resources.router.routes.listarticles.map.2 = "template";

resources.router.routes.listarticles.reverse = "listarticle/%s-%s-%s.html";

 

其中,index路由使我们可以直接访问www.xxx.com/index.html

listarticles路由链接形如:www.xxx.com/listarticles/3-template1.html

这两个例子是结合手册和网上一些文章写成的,根据其规律,举一反三,我们不难按手册写出其它需要的路由。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值