Take the 2-minute tour ×

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

1 Answer 1

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


