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

Our company has created simple CMS app, which it is planning to sell to thousands of small companies. Right now, our CMS app spits out the html files to a pre-configured directory in a directory structure like:


Managing these websites using the virtual hosts is not practical, Right now, we are using a simple rack module which finds the right files based on the HTTP_HOST and returns the appropriate html by reading the file from the hard-drive. This is obviously not an optimal solution.

What would you guys do to solve this?

share|improve this question
up vote 6 down vote accepted

you could generate small configuration file for each directory(virtual host) you have if you need to handle those differently or if you want to save effort use the following:

server {
  server_name   ~^(www\.)?(?<domain>.+)$;
  location / {
    root  /sites/$domain;

This maps the request domain to a directory.

share|improve this answer
works like a charm! Thanks :) – Khaja Minhajuddin Dec 14 '10 at 1:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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