去除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