Setting root based on Host: header

Maxim Dounin mdounin at
Mon Oct 20 01:38:47 MSD 2008


On Sun, Oct 19, 2008 at 11:00:06PM +0200, Samuel Vogel wrote:

> Hey guys,
> Could somebody tell me how I would set the "root"-Variable based up on  
> the contents of the Host: Header?
> I have a host header like this:
> I would like to construct a root like this: /www/345232

Something like:

    set $subdir "default";

    if ($host ~ "^(.+)\.user\.domain\.net$") {
        set $subdir $1;

    root /www/$subdir;

should work.

Maxim Dounin

More information about the nginx mailing list