Yii Framework Forum: Controller And Module With Same Name - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Controller And Module With Same Name Rate Topic: -----

#1 User is offline   gv0zd 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 43
  • Joined: 06-April 12

Posted 06 February 2013 - 05:00 AM

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/do.../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
0

#2 User is offline   egorpromo 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 66
  • Joined: 02-December 12

Posted 06 February 2013 - 09:29 AM

Is it real to use full absolite URL with 'http://' prefix in 'rules'? I think it is not.
0

#3 User is offline   MadAnd 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 109
  • Joined: 16-June 11
  • Location:Ukraine

Posted 06 February 2013 - 09:48 AM

Hi,

in order to process host in your rules, you should set CUrlRule::hasHostInfo to TRUE:

'rules'=>array(
	'http://'.SITE_DOMAIN.'/<action:(download)>/<url:.*>' => array('download/<action>', 'hasHostInfo'=>true),
	'http://<module:(download)>.'.SITE_DOMAIN.'/<code:\w{32}>' => array('<module>', 'hasHostInfo'=>true),
),

0

#4 User is offline   gv0zd 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 43
  • Joined: 06-April 12

Posted 07 February 2013 - 03:43 AM

View Postegorpromo, on 06 February 2013 - 09:29 AM, said:

Is it real to use full absolite URL with 'http://' prefix in 'rules'? I think it is not.

In some caseses I have different rules for http and for https.
0

#5 User is offline   gv0zd 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 43
  • Joined: 06-April 12

Posted 07 February 2013 - 03:52 AM

View PostMadAnd, on 06 February 2013 - 09:48 AM, said:

Hi,

in order to process host in your rules, you should set CUrlRule::hasHostInfo to TRUE:

'rules'=>array(
	'http://'.SITE_DOMAIN.'/<action:(download)>/<url:.*>' => array('download/<action>', 'hasHostInfo'=>true),
	'http://<module:(download)>.'.SITE_DOMAIN.'/<code:\w{32}>' => array('<module>', 'hasHostInfo'=>true),
),


Nothing changed :(
0

#6 User is offline   egorpromo 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 66
  • Joined: 02-December 12

Posted 09 February 2013 - 02:47 AM

I think it is not possible to use domain names in 'rules' of 'urlManager' component. I think it must be implemented via htaccess.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users