Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 and 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.

share|improve this question

closed as not constructive by Magellan, John Gardeniers, EEAA, Michael Hampton, Brent Pabst Nov 27 '12 at 14:16

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

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

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.

share|improve this answer
Something about this seems a bit insecure.. or at least security thru obscurity.. – Tom O'Connor Nov 27 '12 at 16:15

Not the answer you're looking for? Browse other questions tagged or ask your own question.