Yii Framework Forum: subdomain rewrite rules - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

subdomain rewrite rules Rate Topic: -----

#1 User is offline   Vince. 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 432
  • Joined: 29-December 08
  • Location:Los Angeles,CA

Posted 28 July 2009 - 06:51 AM

Does Yii supports subdomain rewrite rules? Like having xx.mydomain.com, yy.mydomain.com etc? I know Zend Does.
Vince Gabriel, Lead Developer.
Posted ImagePosted ImagePosted Image
0

#2 User is offline   Vince. 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 432
  • Joined: 29-December 08
  • Location:Los Angeles,CA

Posted 29 July 2009 - 10:02 AM

Bump.
Vince Gabriel, Lead Developer.
Posted ImagePosted ImagePosted Image
0

#3 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,898
  • Joined: 04-October 08
  • Location:DC, USA

Posted 29 July 2009 - 04:34 PM

Nope. Maybe you can elaborate how this would be used?
0

#4 User is offline   Vince. 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 432
  • Joined: 29-December 08
  • Location:Los Angeles,CA

Posted 30 July 2009 - 02:11 AM

if i have a domain name i use that is domain.com currently you can use domain.com/moduleID/controllerID/actionID to make this redirect to a certain action in a controller. You can also write rules, But all of this will need to be after the domain and as the path info. Zend allows you to do actionID.domain.com and it will redirect that to that action based on a rule you specify.
Vince Gabriel, Lead Developer.
Posted ImagePosted ImagePosted Image
1

#5 User is offline   TigerMunky 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 23-July 09
  • Location:Johannesburg, South Africa

Posted 03 August 2009 - 07:51 AM

View Postqiang, on 29 July 2009 - 04:34 PM, said:

Nope. Maybe you can elaborate how this would be used?



Yes, I also would like to be able to do the following:

username.domain.com - goes to the user's profile

blog.domain.com - writing about the domain

pics.domain.com - checkout all our photo's

etc.
TM

"Go Team!"
0

#6 User is offline   Y!! 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 978
  • Joined: 18-June 09

Posted 04 August 2009 - 04:48 AM

I'm also interested in something like that in order to do multi-language sites based on the subdomain.

http://de.example.com/
http://en.example.com/

Also different url-rules should be supported based on the subdomain (and throw an error even if the path is available at the other subdomain).

http://de.example.com/kontakt/
http://en.example.com/contact/

I have to write my own UrlManager class, I guess.
0

#7 User is offline   Vince. 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 432
  • Joined: 29-December 08
  • Location:Los Angeles,CA

Posted 05 August 2009 - 02:15 AM

Yea that's an example of one way of using it.
Vince Gabriel, Lead Developer.
Posted ImagePosted ImagePosted Image
0

#8 User is offline   qq71151461 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 386
  • Joined: 05-June 09

Posted 11 October 2009 - 05:11 AM

强烈关注
0

#9 User is offline   Vince. 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 432
  • Joined: 29-December 08
  • Location:Los Angeles,CA

Posted 18 October 2009 - 10:38 AM

Bump.
Vince Gabriel, Lead Developer.
Posted ImagePosted ImagePosted Image
0

#10 User is offline   Vince. 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 432
  • Joined: 29-December 08
  • Location:Los Angeles,CA

Posted 02 November 2009 - 04:22 AM

Is this something the 1.0 series will have?
Vince Gabriel, Lead Developer.
Posted ImagePosted ImagePosted Image
0

#11 User is offline   datashaman 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 56
  • Joined: 27-September 09
  • Location:Cape Town, South Africa

Posted 02 November 2009 - 04:54 AM

You could use a combination of dynamic controller and lookup the virtual host by URI. Then use the following pattern in your own subclassed URLManager:

class UrlManager extends CUrlManager
{
  private function getRules()
  {
     switch($site->type) {
       case 'admin':
         $rules = array(
          ...
         );
       case 'vhost':
          ...
       case 'blah':
         ...
     }
     return $rules;
  }

  protected function processRules()
  {
    $this->rules = $this->getRules();
    return parent::processRules();
  }
}


You can also define your getRules method like so, to continue defining rules in the config, but then you lose the ability to alter the rules dynamically.

private function getRules()
{
  return Yii::app()->param->rules[SiteController::getSite()->type];
}


and put your rules in params:

return array(
  'params' => array(
    'rules' => array(
      'admin' => array(
         ...
      ),
      ...
    ),
  ),
);


This gives you customized views, rules and controllers per virtual domain.

EDIT:

On second thoughts, the UrlManager's rules property can be used as is, instead of adding it as a params entry.

In that case, make sure your rules are grouped into site types as above (under the UrlManager component's entry in config/main.php), and use the following in getRules():

private function getRules()
{
  return $this->rules[SiteController::getSite()->type];
}

This post has been edited by datashaman: 02 November 2009 - 04:58 AM

1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

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