diff options
author | Igor Sysoev <igor@sysoev.ru> | 2008-05-26 18:57:43 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2008-05-26 18:57:43 +0000 |
commit | 626cd7e7be4d40d19e75e0960752c64aebd544d9 (patch) | |
tree | 803d2766c8249da2a35322736376c923a867b70f /src/http/modules/ngx_http_static_module.c | |
parent | d412ece2fcd45fd771b74ea5496301b8cb7611ab (diff) | |
download | nginx-626cd7e7be4d40d19e75e0960752c64aebd544d9.tar.gz nginx-626cd7e7be4d40d19e75e0960752c64aebd544d9.zip |
add args in redirect to a directory
Diffstat (limited to 'src/http/modules/ngx_http_static_module.c')
-rw-r--r-- | src/http/modules/ngx_http_static_module.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/http/modules/ngx_http_static_module.c b/src/http/modules/ngx_http_static_module.c index c4e688ffb..03d75cd80 100644 --- a/src/http/modules/ngx_http_static_module.c +++ b/src/http/modules/ngx_http_static_module.c @@ -48,7 +48,7 @@ static ngx_int_t ngx_http_static_handler(ngx_http_request_t *r) { u_char *last, *location; - size_t root; + size_t root, len; ngx_str_t path; ngx_int_t rc; ngx_uint_t level; @@ -150,26 +150,39 @@ ngx_http_static_handler(ngx_http_request_t *r) return NGX_HTTP_INTERNAL_SERVER_ERROR; } - if (!clcf->alias && clcf->root_lengths == NULL) { + len = r->uri.len + 1; + + if (!clcf->alias && clcf->root_lengths == NULL && r->args.len == 0) { location = path.data + clcf->root.len; + *last = '/'; + } else { - location = ngx_palloc(r->pool, r->uri.len + 1); + if (r->args.len) { + len += r->args.len + 1; + } + + location = ngx_palloc(r->pool, len); if (location == NULL) { return NGX_HTTP_INTERNAL_SERVER_ERROR; } last = ngx_copy(location, r->uri.data, r->uri.len); - } - *last = '/'; + *last = '/'; + + if (r->args.len) { + *++last = '?'; + ngx_memcpy(++last, r->args.data, r->args.len); + } + } /* * we do not need to set the r->headers_out.location->hash and * r->headers_out.location->key fields */ - r->headers_out.location->value.len = r->uri.len + 1; + r->headers_out.location->value.len = len; r->headers_out.location->value.data = location; return NGX_HTTP_MOVED_PERMANENTLY; |