rewrite rules issue

Francis Daly francis at
Sun Apr 19 11:04:38 UTC 2015

On Sun, Apr 19, 2015 at 04:06:55AM -0400, nicocolt wrote:

Hi there,

> Here is the directory path:
> /var/www/
> my nginx conf is:
> root /var/www/
> if ($http_host = "") {
>             rewrite ^(?!/\b(subdomain|stats|error)\b)/(.*)$ /subdomain/$2
> last;
> }
> The if statement is before all of location directives.
> After purging my cache browser, this is what I get:
> when i reach i'm redirected to
> (this is not what i want, i
> want

Ok, this makes a bit more sense now: your request actually might use
the configuration shown.

Are you sure that you have copy-pasted exactly the response? I would have
expected a redirect to
-- but the actual redirect comes from the configuration that you have
not yet shown.

Your rewrite says that you *do* want the request to be handled like, so I'm still not sure
what the actual full end intention is.

It does look to me like

 root /var/www/;

is probably what you really want, but I guess there is some reason why
you don't just use that?

Good luck with it,

Francis Daly        francis at

More information about the nginx mailing list