Search code examples
.htaccesszend-framework2subdomainuser-registration

ZF2 User Register and creation of a Subdomain


Im using the ZF 2 Framework and have the follow scenario.

  1. Company can register
  2. After Register it creates a subdomain (need changes in the .htaccess)

Example :

  • site.com => Frontend
  • company_a.site.com => Frontend for Company (company_id=1)
  • compaby_b.site.com => Frontend for Company (company_id=2)

What i want is that when a Users goes to company_a.site.com or company_b.site.com, that the Route is the same in the Application but the Data from DB depens on the subdomain name.

How i think it must work :

  1. User comes to company_a.site.com
  2. In the Main Controller i will make a Query to DB to see if exists a company with name "company_a" and if is so then assign a global variable with the company ID from the DB. So i can based on that ID load the content for the frontend.

Solution

  • I find the solution with the ZF 2 Route Hostname type