rewrite rules issue

nicocolt nginx-forum at nginx.us
Sun Apr 19 08:06:55 UTC 2015


Hello 

Thanks for your reply.

If I remove the three lines, i get a 404 error. As a reminder, and maybe a
little bit more clear :) here is the configuration.

Here is the directory path:

/var/www/domain.fr/web/subdomain/directory

my nginx conf is:

root /var/www/domain.fr/web

if ($http_host = "subdomain.domain.fr") {
            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 http://subdomain.domain.fr/directory i'm redirected to
http://subdomain.domain.fr/subdomain/directory (this is not what i want, i
want http://subdomain.domain.fr/directory)

Thanks fo your help,
Best regards,
Nico

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,258184,258190#msg-258190



More information about the nginx mailing list