nginx-0.0.7-2004-07-18-23:11:20 import
diff --git a/src/http/modules/ngx_http_access_handler.c b/src/http/modules/ngx_http_access_handler.c
index a57526e..b6fdeab 100644
--- a/src/http/modules/ngx_http_access_handler.c
+++ b/src/http/modules/ngx_http_access_handler.c
@@ -190,13 +190,8 @@
 static ngx_int_t ngx_http_access_init(ngx_cycle_t *cycle)
 {
     ngx_http_handler_pt        *h;
-    ngx_http_conf_ctx_t        *ctx;
     ngx_http_core_main_conf_t  *cmcf;
 
-#if 0
-    ctx = (ngx_http_conf_ctx_t *) cycle->conf_ctx[ngx_http_module.index];
-    cmcf = ctx->main_conf[ngx_http_core_module.ctx_index];
-#endif
     cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module);
 
     h = ngx_push_array(&cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers);
diff --git a/src/http/modules/ngx_http_charset_filter.c b/src/http/modules/ngx_http_charset_filter.c
index d7ce88e..662f0b2 100644
--- a/src/http/modules/ngx_http_charset_filter.c
+++ b/src/http/modules/ngx_http_charset_filter.c
@@ -363,7 +363,6 @@
     ngx_int_t                     *cp;
     ngx_str_t                     *value;
     ngx_http_charset_t            *charset;
-    ngx_http_conf_ctx_t           *ctx;
     ngx_http_charset_main_conf_t  *mcf;
 
     cp = (ngx_int_t *) (p + cmd->offset);
@@ -372,8 +371,9 @@
         return "is duplicate";
     }
 
-    ctx = cf->ctx;
-    mcf = ctx->main_conf[ngx_http_charset_filter_module.ctx_index];
+    mcf = ngx_http_conf_get_module_main_conf(cf,
+                                             ngx_http_charset_filter_module);
+
     value = cf->args->elts;
 
     *cp = ngx_http_add_charset(&mcf->charsets, &value[1]);
diff --git a/src/http/modules/ngx_http_index_handler.c b/src/http/modules/ngx_http_index_handler.c
index 80e4d19..ddd8894 100644
--- a/src/http/modules/ngx_http_index_handler.c
+++ b/src/http/modules/ngx_http_index_handler.c
@@ -98,6 +98,7 @@
 ngx_int_t ngx_http_index_handler(ngx_http_request_t *r)
 {
     u_char                     *name;
+    size_t                      len;
     ngx_fd_t                    fd;
     ngx_int_t                   rc;
     ngx_str_t                  *index;
@@ -160,6 +161,7 @@
 
 #endif
 
+#if 0
         ctx->path.data = ngx_palloc(r->pool, clcf->root.len + r->uri.len
                                              + ilcf->max_index_len
                                              - clcf->alias * clcf->name.len);
@@ -169,9 +171,35 @@
 
         ctx->redirect.data = ngx_cpymem(ctx->path.data, clcf->root.data,
                                         clcf->root.len);
+#endif
 
         if (clcf->alias) {
-            ctx->last = ngx_cpystrn(ctx->redirect.data,
+            if (clcf->root.len > clcf->name.len) {
+                ctx->path.data = ngx_palloc(r->pool, clcf->root.len
+                                                     + r->uri.len
+                                                     - clcf->name.len
+                                                     + ilcf->max_index_len);
+                if (ctx->path.data == NULL) {
+                    return NGX_HTTP_INTERNAL_SERVER_ERROR;
+                }
+
+                ctx->redirect.data = ctx->path.data + clcf->root.len + 1
+                                                              - clcf->name.len;
+
+            } else {
+                ctx->redirect.data = ngx_palloc(r->pool, r->uri.len
+                                                         + ilcf->max_index_len);
+                if (ctx->redirect.data == NULL) {
+                    return NGX_HTTP_INTERNAL_SERVER_ERROR;
+                }
+
+                ctx->path.data = ctx->redirect.data + clcf->name.len
+                                                              - clcf->root.len;
+            }
+
+            ngx_memcpy(ctx->path.data, clcf->root.data, clcf->root.len);
+
+            ctx->last = ngx_cpystrn(ctx->path.data + clcf->root.len,
                                     r->uri.data + clcf->name.len,
                                     r->uri.len + 1 - clcf->name.len);
 
@@ -185,6 +213,15 @@
             }
 
         } else {
+            ctx->path.data = ngx_palloc(r->pool, clcf->root.len + r->uri.len
+                                                 + ilcf->max_index_len);
+            if (ctx->path.data == NULL) {
+                return NGX_HTTP_INTERNAL_SERVER_ERROR;
+            }
+
+            ctx->redirect.data = ngx_cpymem(ctx->path.data, clcf->root.data,
+                                            clcf->root.len);
+
             ctx->last = ngx_cpystrn(ctx->redirect.data, r->uri.data,
                                     r->uri.len + 1);
         }
@@ -255,8 +292,14 @@
             ctx->redirect.data = index[ctx->index].data;
 
         } else {
-            ctx->redirect.len = r->uri.len + index[ctx->index].len;
+            if (clcf->alias) {
+                ngx_memcpy(ctx->redirect.data, clcf->name.data, clcf->name.len);
+            }
+
+            ctx->redirect.len = r->uri.len + index[ctx->index].len
+                                                - clcf->alias * clcf->name.len;
             r->file.name.len = clcf->root.len + r->uri.len
+                                                - clcf->alias * clcf->name.len
                                                        + index[ctx->index].len;
         }
 
@@ -364,11 +407,9 @@
 static ngx_int_t ngx_http_index_init(ngx_cycle_t *cycle)
 {
     ngx_http_handler_pt        *h;
-    ngx_http_conf_ctx_t        *ctx;
     ngx_http_core_main_conf_t  *cmcf;
 
-    ctx = (ngx_http_conf_ctx_t *) cycle->conf_ctx[ngx_http_module.index];
-    cmcf = ctx->main_conf[ngx_http_core_module.ctx_index];
+    cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module);
 
     h = ngx_push_array(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers);
     if (h == NULL) {
diff --git a/src/http/modules/ngx_http_rewrite_handler.c b/src/http/modules/ngx_http_rewrite_handler.c
index 7d36b13..5c25c89 100644
--- a/src/http/modules/ngx_http_rewrite_handler.c
+++ b/src/http/modules/ngx_http_rewrite_handler.c
@@ -369,11 +369,9 @@
 static ngx_int_t ngx_http_rewrite_init(ngx_cycle_t *cycle)
 {
     ngx_http_handler_pt        *h;
-    ngx_http_conf_ctx_t        *ctx;
     ngx_http_core_main_conf_t  *cmcf;
 
-    ctx = (ngx_http_conf_ctx_t *) cycle->conf_ctx[ngx_http_module.index];
-    cmcf = ctx->main_conf[ngx_http_core_module.ctx_index];
+    cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module);
 
     h = ngx_push_array(&cmcf->phases[NGX_HTTP_REWRITE_PHASE].handlers);
     if (h == NULL) {
diff --git a/src/http/modules/ngx_http_ssl_module.c b/src/http/modules/ngx_http_ssl_module.c
index 3a8b863..699bd8f 100644
--- a/src/http/modules/ngx_http_ssl_module.c
+++ b/src/http/modules/ngx_http_ssl_module.c
@@ -105,7 +105,8 @@
         return NGX_CONF_ERROR;
     }
 
-    if (SSL_CTX_use_certificate_file(conf->ssl_ctx, conf->certificate.data,
+    if (SSL_CTX_use_certificate_file(conf->ssl_ctx,
+                                     (char *) conf->certificate.data,
                                      SSL_FILETYPE_PEM) == 0) {
         ngx_ssl_error(NGX_LOG_EMERG, cf->log, 0,
                       "SSL_CTX_use_certificate_file(\"%s\") failed",
@@ -113,7 +114,8 @@
         return NGX_CONF_ERROR;
     }
 
-    if (SSL_CTX_use_PrivateKey_file(conf->ssl_ctx, conf->certificate_key.data,
+    if (SSL_CTX_use_PrivateKey_file(conf->ssl_ctx,
+                                    (char *) conf->certificate_key.data,
                                     SSL_FILETYPE_PEM) == 0) {
         ngx_ssl_error(NGX_LOG_EMERG, cf->log, 0,
                       "SSL_CTX_use_PrivateKey_file(\"%s\") failed",
diff --git a/src/http/modules/ngx_http_static_handler.c b/src/http/modules/ngx_http_static_handler.c
index 9c11c7e..bc32cc5 100644
--- a/src/http/modules/ngx_http_static_handler.c
+++ b/src/http/modules/ngx_http_static_handler.c
@@ -537,11 +537,9 @@
 static ngx_int_t ngx_http_static_init(ngx_cycle_t *cycle)
 {
     ngx_http_handler_pt        *h;
-    ngx_http_conf_ctx_t        *ctx;
     ngx_http_core_main_conf_t  *cmcf;
-    
-    ctx = (ngx_http_conf_ctx_t *) cycle->conf_ctx[ngx_http_module.index];
-    cmcf = ctx->main_conf[ngx_http_core_module.ctx_index];
+
+    cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module);
     
     h = ngx_push_array(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers);
     if (h == NULL) {
diff --git a/src/http/modules/ngx_http_status_handler.c b/src/http/modules/ngx_http_status_handler.c
index adf9d02..57d7aa0 100644
--- a/src/http/modules/ngx_http_status_handler.c
+++ b/src/http/modules/ngx_http_status_handler.c
@@ -299,11 +299,9 @@
 
 static char *ngx_http_set_status(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 {
-    ngx_http_conf_ctx_t       *ctx;
     ngx_http_core_loc_conf_t  *clcf;
 
-    ctx = cf->ctx;
-    clcf = ctx->loc_conf[ngx_http_core_module.ctx_index];
+    clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
     clcf->handler = ngx_http_status_handler;
 
     return NGX_CONF_OK;
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c
index 4f8fbda..711aad2 100644
--- a/src/http/modules/proxy/ngx_http_proxy_handler.c
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.c
@@ -1062,7 +1062,6 @@
     in_addr_t                  addr;
     ngx_str_t                 *value;
     struct hostent            *h;
-    ngx_http_conf_ctx_t       *ctx;
     ngx_http_core_loc_conf_t  *clcf;
 
 
@@ -1177,10 +1176,11 @@
                     lcf->upstream->port_text.len + 1);
     }
 
-    ctx = cf->ctx;
-    clcf = ctx->loc_conf[ngx_http_core_module.ctx_index];
+    clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
+
     lcf->upstream->location = &clcf->name;
     clcf->handler = ngx_http_proxy_handler;
+
     if (clcf->name.data[clcf->name.len - 1] == '/') {
         clcf->auto_redirect = 1;
     }