首先是在bootstrap文件中配置你的路由规则,可以正则表达式自由按照你的需求进行配置,我的配置如下:
$route2 = new Zend_Controller_Router_Route_Regex(
'([a-zA-Z-_0-9]+)-(\w+).html',
array(
"module"=>'default',
'controller'=>'hpxg',
'action' =>''
),
array(
1=>'controller',
2=>'action',
3 =>'id'
)
);
$route3 = new Zend_Controller_Router_Route_Regex(
'([a-zA-Z-_0-9]+)-(\w+)-(\w+).html',
array(
"module"=>'default',
'controller'=>'hpxg',
'action' =>''
),
array(
1=>'controller',
2=>'action',
3 =>'gid',
)
);
$router->addRoute('user', $route);
$router->addRoute('user1', $route1);
$router->addRoute('user2', $route2);
然后是关键的修改zend路由设置部分为自己需要的.修改文件rege.php
添加如下:
if(count($values)==2){
$tem = array(1=>'',2=>'',3=>'');
$tem[1] = 'hpxg';
$tem[2] = 'index';
$tem[3] = $values[2];
$values = $tem;
}else{
$tem = array(1=>'',2=>'',3=>'');
$tem[1] = 'hpxg';
$tem[2] = 'goodinfo';
$tem[3] = $values[3];
$values = $tem;
}
如下图,设置完毕