comparison src/http/ngx_http_core_module.c @ 3534:3711bb1336c3

fix a try_files/alias case when alias uses captures and try_files .html "" / =404;
author Igor Sysoev <igor@sysoev.ru>
date Thu, 27 May 2010 13:44:22 +0000
parents bb5376f3f585
children abb3901be800
comparison
equal deleted inserted replaced
3533:bb5376f3f585 3534:3711bb1336c3
1284 1284
1285 #if (NGX_PCRE) 1285 #if (NGX_PCRE)
1286 } else if (clcf->regex) { 1286 } else if (clcf->regex) {
1287 if (!test_dir) { 1287 if (!test_dir) {
1288 r->uri = path; 1288 r->uri = path;
1289 r->add_uri_to_alias = 1;
1289 } 1290 }
1290 #endif 1291 #endif
1291 } else { 1292 } else {
1292 r->uri.len = alias + path.len; 1293 r->uri.len = alias + path.len;
1293 r->uri.data = ngx_pnalloc(r->pool, r->uri.len); 1294 r->uri.data = ngx_pnalloc(r->pool, r->uri.len);
1781 1782
1782 #if (NGX_PCRE) 1783 #if (NGX_PCRE)
1783 ngx_uint_t captures; 1784 ngx_uint_t captures;
1784 1785
1785 captures = alias && clcf->regex; 1786 captures = alias && clcf->regex;
1786 reserved += captures ? 1 : r->uri.len - alias + 1; 1787
1788 reserved += captures ? r->add_uri_to_alias ? r->uri.len + 1 : 1
1789 : r->uri.len - alias + 1;
1787 #else 1790 #else
1788 reserved += r->uri.len - alias + 1; 1791 reserved += r->uri.len - alias + 1;
1789 #endif 1792 #endif
1790 1793
1791 if (ngx_http_script_run(r, path, clcf->root_lengths->elts, reserved, 1794 if (ngx_http_script_run(r, path, clcf->root_lengths->elts, reserved,
1802 *root_length = path->len - reserved; 1805 *root_length = path->len - reserved;
1803 last = path->data + *root_length; 1806 last = path->data + *root_length;
1804 1807
1805 #if (NGX_PCRE) 1808 #if (NGX_PCRE)
1806 if (captures) { 1809 if (captures) {
1807 *last = '\0'; 1810 if (!r->add_uri_to_alias) {
1808 return last; 1811 *last = '\0';
1812 return last;
1813 }
1814
1815 alias = 0;
1809 } 1816 }
1810 #endif 1817 #endif
1811 } 1818 }
1812 1819
1813 last = ngx_cpystrn(last, r->uri.data + alias, r->uri.len - alias + 1); 1820 last = ngx_cpystrn(last, r->uri.data + alias, r->uri.len - alias + 1);
2211 #if (NGX_HTTP_CACHE) 2218 #if (NGX_HTTP_CACHE)
2212 r->cache = NULL; 2219 r->cache = NULL;
2213 #endif 2220 #endif
2214 2221
2215 r->internal = 1; 2222 r->internal = 1;
2223 r->add_uri_to_alias = 0;
2216 r->main->count++; 2224 r->main->count++;
2217 2225
2218 ngx_http_handler(r); 2226 ngx_http_handler(r);
2219 2227
2220 return NGX_DONE; 2228 return NGX_DONE;