zend framework之router 路由器设置

进入application.ini文件,在[production]节添加下面内容

;=========== 路由器设置
;resources.router.routes.0.type = "Zend_Controller_Router_Route_Static"
resources.router.routes.0.route = "archive"
resources.router.routes.0.defaults.module = "front"
resources.router.routes.0.defaults.controller = "index"
resources.router.routes.0.defaults.action = "index"

resources.router.routes.1.type = "Zend_Controller_Router_Route_Regex"
resources.router.routes.1.route = "archive(\d+)-(\d+)/*"
resources.router.routes.1.defaults.module = "front"
resources.router.routes.1.defaults.controller = "index"
resources.router.routes.1.defaults.action = "index"
resources.router.routes.1.map.1 = "year"
resources.router.routes.1.map.2 = "day"
Zend_Controller_Router_Route_Static是静态路由,路由设置成固定,上面注释掉了,使用缺省路由,在这里效果一样
route是设置成的名字  // 该名字是以根目录为基础的
module为指向的module名
controller为指向的controller名
action为指向的action名

第一个设置的地址为 http://localhost/archive/
映射到 http://localhost/index/index/

Zend_Controller_Router_Route_Regex是正则表达式路由类型
第二个设置为带两个数字参数的get传值,并设置索引为year,day
如地址 http://localhost/archive2011-07/
映射到 http://localhost/index/index/?year=2011&day=07

 在controller可以获取参数的值
$getYear = $this->_request->get('year');   //2011
$getDay = $this->_request->get('day');     //07
结束


出处:http://yumena.me/zend-framework-study-notes-6

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值