Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm setting up a new server for my personal stuff. On the old box I've used lighttpd for almost two years now. I've read a bit about it and most people tend to switch to nginx since it's development is much more active.

Now i'm a bit overwhelmed by the might of nginx. The coolest thing I've used with lighty was the "evhost.path-pattern" feature where I can simply delegate all domains and subdomains using a more or less complex regular expression and defining "evhost.path-pattern = "/var/www/pages/%0/subdomains/%3/" so I simply have to create a new folder in "subdomains" and the same second I have a working webdir to upload stuff for the new subdomain (or new domain).

Nginx has this construct:

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

    location / {
        root   /sites/$domain;
    }
}

But now I have problems finding a proper RegEx to cover domains and subdomains at the same time (in lighty I've done this by having a RegEx to have catch the domain and negate it for subdomains). I want the main domain (with and without 'www') to go to /var/www/pages//htdocs/ and all subdomains need to go to /var/www/pages//subdomains//.

Any help on this?

share|improve this question
    
OK, i've figured it out. I have now two server{}. One for main domains (with and without www) and one for subdomains, each with a suitable RegEx to get domain and subdomain name. –  Manuel Mar 14 '12 at 13:53

1 Answer 1

convert from comment to CW

I have now two server{} directive.

One for main domains (with and without www) and one for subdomains, each with a suitable regex to get domain and subdomain name.

share|improve this answer

Your Answer

 
discard

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.