aboutsummaryrefslogtreecommitdiff
path: root/src/http/modules/ngx_http_static_handler.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2004-03-16 07:10:12 +0000
committerIgor Sysoev <igor@sysoev.ru>2004-03-16 07:10:12 +0000
commit10a543a810ac78eb5d754302b001debf9cd420c4 (patch)
treea4a4f43835bed4549007b82db516d460fc86c555 /src/http/modules/ngx_http_static_handler.c
parent5596ede94ed311bb9d16ee11f6f68c97eb46d836 (diff)
downloadnginx-10a543a810ac78eb5d754302b001debf9cd420c4.tar.gz
nginx-10a543a810ac78eb5d754302b001debf9cd420c4.zip
nginx-0.0.2-2004-03-16-10:10:12 import
Diffstat (limited to 'src/http/modules/ngx_http_static_handler.c')
-rw-r--r--src/http/modules/ngx_http_static_handler.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/http/modules/ngx_http_static_handler.c b/src/http/modules/ngx_http_static_handler.c
index 7876d2a24..0576255eb 100644
--- a/src/http/modules/ngx_http_static_handler.c
+++ b/src/http/modules/ngx_http_static_handler.c
@@ -60,7 +60,7 @@ ngx_module_t ngx_http_static_module = {
static ngx_int_t ngx_http_static_handler(ngx_http_request_t *r)
{
- char *last;
+ u_char *last;
ngx_fd_t fd;
ngx_int_t rc;
ngx_uint_t level;
@@ -115,14 +115,31 @@ static ngx_int_t ngx_http_static_handler(ngx_http_request_t *r)
* in a possible redirect and for the last '\0'
*/
- name.data = ngx_palloc(r->pool, clcf->doc_root.len + r->uri.len + 2);
+ name.data = ngx_palloc(r->pool, clcf->root.len + r->uri.len + 2
+ - clcf->alias * clcf->name.len);
if (name.data == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
- location.data = ngx_cpymem(name.data, clcf->doc_root.data,
- clcf->doc_root.len);
- last = ngx_cpystrn(location.data, r->uri.data, r->uri.len + 1);
+ location.data = ngx_cpymem(name.data, clcf->root.data, clcf->root.len);
+
+ if (clcf->alias) {
+ last = ngx_cpystrn(location.data, r->uri.data + clcf->name.len,
+ r->uri.len + 1 - clcf->name.len);
+
+ /*
+ * aliases usually have trailling "/",
+ * set it in the start of the possible redirect
+ */
+
+ if (*location.data != '/') {
+ location.data--;
+ }
+
+ } else {
+ last = ngx_cpystrn(location.data, r->uri.data, r->uri.len + 1);
+ }
+
name.len = last - name.data;
location.len = last - location.data + 1;