comparison src/http/modules/ngx_http_index_module.c @ 813:a608349951cf

fix alias without trailing slash
author Igor Sysoev <igor@sysoev.ru>
date Wed, 25 Oct 2006 15:36:11 +0000
parents c3ebeee31026
children ff762576da78
comparison
equal deleted inserted replaced
812:3298810a0198 813:a608349951cf
313 313
314 314
315 static ngx_int_t 315 static ngx_int_t
316 ngx_http_index_test_dir(ngx_http_request_t *r, ngx_http_index_ctx_t *ctx) 316 ngx_http_index_test_dir(ngx_http_request_t *r, ngx_http_index_ctx_t *ctx)
317 { 317 {
318 u_char c;
319 ngx_uint_t i;
318 ngx_err_t err; 320 ngx_err_t err;
319 ngx_file_info_t fi; 321 ngx_file_info_t fi;
320 322
321 *(ctx->index.data - 1) = '\0'; 323 c = *(ctx->index.data - 1);
324 i = (c == '/') ? 1 : 0;
325 *(ctx->index.data - i) = '\0';
322 326
323 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 327 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
324 "http index check dir: \"%s\"", ctx->path.data); 328 "http index check dir: \"%s\"", ctx->path.data);
325 329
326 if (ngx_file_info(ctx->path.data, &fi) == -1) { 330 if (ngx_file_info(ctx->path.data, &fi) == -1) {
327 331
328 err = ngx_errno; 332 err = ngx_errno;
329 333
330 if (err == NGX_ENOENT) { 334 if (err == NGX_ENOENT) {
331 *(ctx->index.data - 1) = '/'; 335 *(ctx->index.data - i) = c;
332 return ngx_http_index_error(r, ctx, err); 336 return ngx_http_index_error(r, ctx, err);
333 } 337 }
334 338
335 ngx_log_error(NGX_LOG_CRIT, r->connection->log, err, 339 ngx_log_error(NGX_LOG_CRIT, r->connection->log, err,
336 ngx_file_info_n " \"%s\" failed", ctx->path.data); 340 ngx_file_info_n " \"%s\" failed", ctx->path.data);
337 341
338 return NGX_HTTP_INTERNAL_SERVER_ERROR; 342 return NGX_HTTP_INTERNAL_SERVER_ERROR;
339 } 343 }
340 344
341 *(ctx->index.data - 1) = '/'; 345 *(ctx->index.data - i) = c;
342 346
343 if (ngx_is_dir(&fi)) { 347 if (ngx_is_dir(&fi)) {
344 return NGX_OK; 348 return NGX_OK;
345 } 349 }
346 350