去除Yii的网址,从ongSpcl#index
别的东西改变节目类别动作后index
,再加入'/ongSpcl' => 'ongSpcl/index'
,
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'/ongSpcl' => 'ongSpcl/index',
'/ongSpcl/<category:.*?>'=>'ongSpcl/show',
),
),
存根测试路线
class RoutingTest extends CTestCase {
public function createUrl($route, $params=array()) {
$url = explode('phpunit', Yii::app()->createUrl($route, $params));
return $url[1];
}
public function testCorrectRoutes() {
$this->assertEquals('/ongSpcl', $this->createUrl('ongSpcl/index'));
$this->assertEquals('/ongSpcl/sp1', $this->createUrl('ongSpcl/show', array('category' => 'sp1'));
//
}
感谢您的答复BT答案没有解决我的目标。我提供的代码是做gr8(它读取abc.co/ongSpcl/category1为abc.co/ongSpcl?category=category1)bt我想为“index”添加一个异常,所以dat abc.co/ongSpcl/index将会b阅读为abc.co/ongSpcl/index – iThink
我仍然把你引向我的答案。如果你发布完整的urlManager代码,这可能会有所帮助。 – ldg