1

我有同名的控制器和模块:下载

'urlManager'=>array(
    'urlFormat'=>'path',
    'showScriptName'=>false,
    'rules'=>array(
        'http://'.SITE_DOMAIN.'/<action:(download)>/<url:.*>'=>'<action>',
        'http://<module:(download)>.'.SITE_DOMAIN.'/<code:\w{32}>'=>'<module>',
    ),
)

所以我想链接如下:http ://domain.com/download/dir1/dir2/file1.zip

被路由到:application/controllers/DownloadController

其中 $_GET['url']=='dir1/dir2/file1.zip'

和像这样的链接:http: //download.site.com/some_code

被路由到:application/modules/download/controllers/DefaultController.php

其中 $_GET['code']=='some_code'

但是现在两种类型的链接都被路由到:application/modules/download/controllers/DefaultController.php

我不明白为什么

4

1 回答 1

1

Try with this:

'urlManager'=>array(
    'urlFormat'=>'path',
    'showScriptName'=>false,
    'rules'=>array(
        'http://'.SITE_DOMAIN.'/download/<url:.*>'=>'Download/index',
        'http://download.'.SITE_DOMAIN.'/<code:\w{32}>'=>'Download/Default/index',
    ),
)

Note: both URLs will be routed to the index action of they own controller.

于 2013-02-11T11:14:26.123 回答