1

I have controller and module with same name: download

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

So I want to links like: http://domain.com/download/dir1/dir2/file1.zip

to be routed to: application/controllers/DownloadController

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

And links like: http://download.site.com/some_code

to be routed to: application/modules/download/controllers/DefaultController.php

where $_GET['code']=='some_code'

But now both types of links are routed to: application/modules/download/controllers/DefaultController.php

I can't understand why

5
  • please show SITE_DOMAIN in site.com and download.site.com. And move forward 'http://<module:(download)>.'.SITE_DOMAIN.'/<code:\w{32}>'=>'<module>', as first element in rules array Commented Feb 6, 2013 at 13:33
  • I use constant for different domains like site.com and site local. Commented Feb 6, 2013 at 14:15
  • I've tried to move subdomain rule at first place, and got the same result Commented Feb 6, 2013 at 14:34
  • Check and show your constant definition Commented Feb 7, 2013 at 5:12
  • define('SITE_DOMAIN', 'site.com'); I have a lot of rules, all of them work proparly. Commented Feb 7, 2013 at 8:39

1 Answer 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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.