Yii Framework Forum: Multi-Tenant Domain Mapping - Yii Framework Forum

Jump to content

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

Multi-Tenant Domain Mapping Rate Topic: -----

#1 User is offline   Ƒяąȼţąℓ ϻɨɲď 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 76
  • Joined: 04-May 12

Posted 30 October 2012 - 11:35 PM

Ok, I try to build a SAAS that can route multiple domains and trigger the appropriate view.

I need to:

1- Parse the domain:
"http://exemple.com" to "exemple"
"http://sub.exemple.com" to "sub" + "exemple"
2- Compare with DB to get tenantID
3- Display the view with the correct domain "http://exemple.com/site/whatever"


Now I tried to understand URLmanager my guess would be something like this:

'http://<testSub:\w+>.<testDomain:\w+>.com/'=>'site/index',
'http://<testDomain:\w+>.com/'=>'site/index'


Now I would love to access the domain and subdomain like this, it would be awesome...
$mySubDomain = Yii::app()->params['testSub'];
$mydomain = Yii::app()->params['testDomain'];


Basically, I try to route multiple domains with a DB. How can I extract the domain name and still have the right URL in the address bar?

Thank you for your time :lol:
0

#2 User is offline   Ƒяąȼţąℓ ϻɨɲď 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 76
  • Joined: 04-May 12

Posted 31 October 2012 - 01:17 PM

up! :rolleyes:
0

#3 User is offline   Rodrigo Coelho 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 665
  • Joined: 05-August 10
  • Location:Rio de Janeiro, Brazil

Posted 31 October 2012 - 03:22 PM

Please take a look at URL Management on the guide and at dburlmanager for inspiration.
Then you'll be able to do it.
Please post again if you need specific instructions.
0

#4 User is offline   Ƒяąȼţąℓ ϻɨɲď 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 76
  • Joined: 04-May 12

Posted 31 October 2012 - 06:26 PM

Thank you, I will have a shot at it but is there a way I can test multiple domains locally without paying parking?
0

#5 User is offline   Rodrigo Coelho 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 665
  • Joined: 05-August 10
  • Location:Rio de Janeiro, Brazil

Posted 31 October 2012 - 08:36 PM

Yes. You can setup fake domain names on your hosts file.
0

#6 User is offline   Ƒяąȼţąℓ ϻɨɲď 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 76
  • Joined: 04-May 12

Posted 31 October 2012 - 10:43 PM

View PostRodrigo Coelho, on 31 October 2012 - 08:36 PM, said:

Yes. You can setup fake domain names on your hosts file.


Of course, I totally forgot about that.

Thank you :lol:
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