Opened 8 years ago
Closed 8 years ago
#1113 closed defect (invalid)
root variable in location reset to default value (/usr/share/nginx/html) when using rewrite in this location
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | nginx-core | Version: | 1.10.x |
Keywords: | Cc: | ||
uname -a: | Linux localserver 4.7.0-1-amd64 #1 SMP Debian 4.7.5-1 (2016-09-26) x86_64 GNU/Linux | ||
nginx -V: | nginx version: nginx/1.10.1 |
Description
"root" changes to global value (defined in server section or /usr/share/nginx/html if root not defined), and redefine "root" in location haven't any result.
Example:
server {
server_name local;
error_log /var/log/nginx/error.log debug;
root /some/www/folder;
location /path {
root /another/www/folder;
rewrite /path(.*)$ $1 last;
}
}
I got a 404 page error when I trying to open local/path/index.html
and logs:
user@local:$ grep "/some/www/folder/" local.error.log
2016/10/18 12:55:44 [debug] 602#602: *4 http filename: "/some/www/folder/index.html"
2016/10/18 12:55:44 [error] 602#602: *4 open() "/some/www/folder/index.html" failed (2: No such file or directory), client: 127.0.0.1, server: local, request: "GET /path/index.html HTTP/1.1", host: "local"
According to the documentation of the
rewrite
directive:The changed URI in your case is
/index.html
, and it doesn't match the/path
location.