Klaus Demo nginx / 626cd7e
add args in redirect to a directory Igor Sysoev 14 years ago
1 changed file(s) with 20 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
4747 ngx_http_static_handler(ngx_http_request_t *r)
4848 {
4949 u_char *last, *location;
50 size_t root;
50 size_t root, len;
5151 ngx_str_t path;
5252 ngx_int_t rc;
5353 ngx_uint_t level;
149149 return NGX_HTTP_INTERNAL_SERVER_ERROR;
150150 }
151151
152 if (!clcf->alias && clcf->root_lengths == NULL) {
152 len = r->uri.len + 1;
153
154 if (!clcf->alias && clcf->root_lengths == NULL && r->args.len == 0) {
153155 location = path.data + clcf->root.len;
154156
157 *last = '/';
158
155159 } else {
156 location = ngx_palloc(r->pool, r->uri.len + 1);
160 if (r->args.len) {
161 len += r->args.len + 1;
162 }
163
164 location = ngx_palloc(r->pool, len);
157165 if (location == NULL) {
158166 return NGX_HTTP_INTERNAL_SERVER_ERROR;
159167 }
160168
161169 last = ngx_copy(location, r->uri.data, r->uri.len);
162 }
163
164 *last = '/';
170
171 *last = '/';
172
173 if (r->args.len) {
174 *++last = '?';
175 ngx_memcpy(++last, r->args.data, r->args.len);
176 }
177 }
165178
166179 /*
167180 * we do not need to set the r->headers_out.location->hash and
168181 * r->headers_out.location->key fields
169182 */
170183
171 r->headers_out.location->value.len = r->uri.len + 1;
184 r->headers_out.location->value.len = len;
172185 r->headers_out.location->value.data = location;
173186
174187 return NGX_HTTP_MOVED_PERMANENTLY;