mirror of
https://github.com/nginx/nginx.git
synced 2025-06-29 18:50:39 +08:00
fix a try_files/alias case when alias uses captures and
try_files .html "" / =404;
This commit is contained in:
parent
ef0fae4279
commit
34ab21c53a
@ -1286,6 +1286,7 @@ ngx_http_core_try_files_phase(ngx_http_request_t *r,
|
|||||||
} else if (clcf->regex) {
|
} else if (clcf->regex) {
|
||||||
if (!test_dir) {
|
if (!test_dir) {
|
||||||
r->uri = path;
|
r->uri = path;
|
||||||
|
r->add_uri_to_alias = 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
@ -1783,7 +1784,9 @@ ngx_http_map_uri_to_path(ngx_http_request_t *r, ngx_str_t *path,
|
|||||||
ngx_uint_t captures;
|
ngx_uint_t captures;
|
||||||
|
|
||||||
captures = alias && clcf->regex;
|
captures = alias && clcf->regex;
|
||||||
reserved += captures ? 1 : r->uri.len - alias + 1;
|
|
||||||
|
reserved += captures ? r->add_uri_to_alias ? r->uri.len + 1 : 1
|
||||||
|
: r->uri.len - alias + 1;
|
||||||
#else
|
#else
|
||||||
reserved += r->uri.len - alias + 1;
|
reserved += r->uri.len - alias + 1;
|
||||||
#endif
|
#endif
|
||||||
@ -1804,8 +1807,12 @@ ngx_http_map_uri_to_path(ngx_http_request_t *r, ngx_str_t *path,
|
|||||||
|
|
||||||
#if (NGX_PCRE)
|
#if (NGX_PCRE)
|
||||||
if (captures) {
|
if (captures) {
|
||||||
*last = '\0';
|
if (!r->add_uri_to_alias) {
|
||||||
return last;
|
*last = '\0';
|
||||||
|
return last;
|
||||||
|
}
|
||||||
|
|
||||||
|
alias = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -2213,6 +2220,7 @@ ngx_http_internal_redirect(ngx_http_request_t *r,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
r->internal = 1;
|
r->internal = 1;
|
||||||
|
r->add_uri_to_alias = 0;
|
||||||
r->main->count++;
|
r->main->count++;
|
||||||
|
|
||||||
ngx_http_handler(r);
|
ngx_http_handler(r);
|
||||||
|
@ -437,6 +437,7 @@ struct ngx_http_request_s {
|
|||||||
|
|
||||||
unsigned invalid_header:1;
|
unsigned invalid_header:1;
|
||||||
|
|
||||||
|
unsigned add_uri_to_alias:1;
|
||||||
unsigned valid_location:1;
|
unsigned valid_location:1;
|
||||||
unsigned valid_unparsed_uri:1;
|
unsigned valid_unparsed_uri:1;
|
||||||
unsigned uri_changed:1;
|
unsigned uri_changed:1;
|
||||||
|
Loading…
Reference in New Issue
Block a user