add args in redirect to a directory
Igor Sysoev
14 years ago
47 | 47 | ngx_http_static_handler(ngx_http_request_t *r) |
48 | 48 | { |
49 | 49 | u_char *last, *location; |
50 | size_t root; | |
50 | size_t root, len; | |
51 | 51 | ngx_str_t path; |
52 | 52 | ngx_int_t rc; |
53 | 53 | ngx_uint_t level; |
149 | 149 | return NGX_HTTP_INTERNAL_SERVER_ERROR; |
150 | 150 | } |
151 | 151 | |
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) { | |
153 | 155 | location = path.data + clcf->root.len; |
154 | 156 | |
157 | *last = '/'; | |
158 | ||
155 | 159 | } 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); | |
157 | 165 | if (location == NULL) { |
158 | 166 | return NGX_HTTP_INTERNAL_SERVER_ERROR; |
159 | 167 | } |
160 | 168 | |
161 | 169 | 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 | } | |
165 | 178 | |
166 | 179 | /* |
167 | 180 | * we do not need to set the r->headers_out.location->hash and |
168 | 181 | * r->headers_out.location->key fields |
169 | 182 | */ |
170 | 183 | |
171 | r->headers_out.location->value.len = r->uri.len + 1; | |
184 | r->headers_out.location->value.len = len; | |
172 | 185 | r->headers_out.location->value.data = location; |
173 | 186 | |
174 | 187 | return NGX_HTTP_MOVED_PERMANENTLY; |