Mercurial > hg > nginx
diff src/http/modules/ngx_http_static_handler.c @ 290:87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 16 Mar 2004 07:10:12 +0000 |
parents | f81d075ad172 |
children | 5cfd65b8b0a7 |
line wrap: on
line diff
--- a/src/http/modules/ngx_http_static_handler.c +++ b/src/http/modules/ngx_http_static_handler.c @@ -60,7 +60,7 @@ ngx_module_t ngx_http_static_module = { static ngx_int_t ngx_http_static_handler(ngx_http_request_t *r) { - char *last; + u_char *last; ngx_fd_t fd; ngx_int_t rc; ngx_uint_t level; @@ -115,14 +115,31 @@ static ngx_int_t ngx_http_static_handler * in a possible redirect and for the last '\0' */ - name.data = ngx_palloc(r->pool, clcf->doc_root.len + r->uri.len + 2); + name.data = ngx_palloc(r->pool, clcf->root.len + r->uri.len + 2 + - clcf->alias * clcf->name.len); if (name.data == NULL) { return NGX_HTTP_INTERNAL_SERVER_ERROR; } - location.data = ngx_cpymem(name.data, clcf->doc_root.data, - clcf->doc_root.len); - last = ngx_cpystrn(location.data, r->uri.data, r->uri.len + 1); + location.data = ngx_cpymem(name.data, clcf->root.data, clcf->root.len); + + if (clcf->alias) { + last = ngx_cpystrn(location.data, r->uri.data + clcf->name.len, + r->uri.len + 1 - clcf->name.len); + + /* + * aliases usually have trailling "/", + * set it in the start of the possible redirect + */ + + if (*location.data != '/') { + location.data--; + } + + } else { + last = ngx_cpystrn(location.data, r->uri.data, r->uri.len + 1); + } + name.len = last - name.data; location.len = last - location.data + 1;