-1

I am building office management software on a LAMP server on a SAAS model. My clients typically have 5-10 thousand customers they are tracking with all of their contact, invoicing, appointment information. I want to keep each clients information in a separate Database. This I believe will in the long run improve performance, ensure better separation of data, and be cleaner.

So what I want to have happen is for company1.mysite.com and company2.mysite.com to both point to the same site, but pass on their subdomain as a parameter to php.

How do I use apache and vhosts to pass on the subdomain as a parameter to php while still using the same application for all subdomains.

4
  • Database architecture is probably way off topic here, IMHO. Nov 27, 2012 at 5:13
  • Well, more so I'm interested in structuring it from the Apache perspective with subdomains. Like company1.mysite.com connects to company1 database while company2.mysite.com connects to company2 database. That's what I think I want, but am open to suggestions if there is a better way. Nov 27, 2012 at 5:22
  • Apache knows nothing about the database your application uses. You'll need to handle that in php.
    – EEAA
    Nov 27, 2012 at 6:17
  • I just edited the question, I didn't explain what I wanted very well Nov 27, 2012 at 14:08

1 Answer 1

2

This probably belongs on Stack Overflow, but...

In your PHP code, you check the value of $_SERVER['HTTP_HOST'] to determine the hostname which was used.

In your Apache <VirtualHost> use a wildcard ServerAlias to serve all possible subdomains of the domain name from the same virtual host.

1
  • Something about this seems a bit insecure.. or at least security thru obscurity.. Nov 27, 2012 at 16:15

Not the answer you're looking for? Browse other questions tagged .