2011-10-09 3 views
0
'urlManager'=>array(
      'urlFormat'=>'path', 
      'rules'=>array(
       'ongSpcl/<category:.*?>'=>'ongSpcl/index', 
      ), 
     ), 

위의 코드는 abc.co/ongSpcl?category=sp1 의미가 있습니다! "로 URL"abc.co/ongSpcl/sp1 "를 읽어하지만 내 문제는 내가 모든을 읽을 수있다 을 제외하고는 위의 형식으로 URL "abc.co/ongSpcl/ 인덱스는"urlManager는 YII에

답변

0

는 기존의 규칙 이전에 (어떤 경로 당신이 원하는 할 수있는 권리 측면 변경) 'ongSpcl/index'=>ongSpcl/index에 대한 규칙을 넣습니다. YII가 첫 경기를 실행합니다

또한 fyi는 <category:\w+>에서 까지 사용할 수 있습니다. 귀하의 의도 인 경우 영숫자가 아닌 모든 문자열이 일치합니다 (). 대답은 BT는 YII URL, 뭔가 다른 ongSpcl#index에서 변화 쇼 카테고리 액션에서 index 후행 제거

+0

감사를

'urlManager'=>array( 'urlFormat'=>'path', 'rules'=>array( '/ongSpcl' => 'ongSpcl/index', '/ongSpcl/<category:.*?>'=>'ongSpcl/show', ), ), 

스텁을 추가 내 목적을 해결하지 못해. 내가 제공 한 코드는 gr8을 수행하고있다 (abc.co/ongSpcl/category1는 abc.co/ongSpcl?category=category1로 읽음) bt "abc.co/ongSpcl/index는 b에 대해"인덱스에 대한 예외를 추가하고 싶다. abc.co/ongSpcl/index – iThink

+0

나는 여전히 내 대답을 소개합니다. 아마도 전체 urlManager 코드를 게시하면 도움이 될 것입니다. – ldg

0

, 다음 응답을 테스트 경로를 들면, '/ongSpcl' => 'ongSpcl/index'

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')); 
    // 
    } 
관련 문제