fix a try_files/alias case when alias uses captures and
     try_files  .html  ""  /  =404;
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index a91d585..f7c4484 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -1286,6 +1286,7 @@
         } else if (clcf->regex) {
             if (!test_dir) {
                 r->uri = path;
+                r->add_uri_to_alias = 1;
             }
 #endif
         } else {
@@ -1783,7 +1784,9 @@
         ngx_uint_t  captures;
 
         captures = alias && clcf->regex;
-        reserved += captures ? 1 : r->uri.len - alias + 1;
+
+        reserved += captures ? r->add_uri_to_alias ? r->uri.len + 1 : 1
+                             : r->uri.len - alias + 1;
 #else
         reserved += r->uri.len - alias + 1;
 #endif
@@ -1804,8 +1807,12 @@
 
 #if (NGX_PCRE)
         if (captures) {
-            *last = '\0';
-            return last;
+            if (!r->add_uri_to_alias) {
+                *last = '\0';
+                return last;
+            }
+
+            alias = 0;
         }
 #endif
     }
@@ -2213,6 +2220,7 @@
 #endif
 
     r->internal = 1;
+    r->add_uri_to_alias = 0;
     r->main->count++;
 
     ngx_http_handler(r);
diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h
index f962271..0559b46 100644
--- a/src/http/ngx_http_request.h
+++ b/src/http/ngx_http_request.h
@@ -437,6 +437,7 @@
 
     unsigned                          invalid_header:1;
 
+    unsigned                          add_uri_to_alias:1;
     unsigned                          valid_location:1;
     unsigned                          valid_unparsed_uri:1;
     unsigned                          uri_changed:1;