]> git.kaiwu.me - nginx.git/commitdiff
allow directories in try_files
authorIgor Sysoev <igor@sysoev.ru>
Wed, 21 Jan 2009 12:11:22 +0000 (12:11 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Wed, 21 Jan 2009 12:11:22 +0000 (12:11 +0000)
src/http/ngx_http_core_module.c
src/http/ngx_http_core_module.h

index d44933ca3628f84b2ef6dfb5d01a7d6b67ccb493..c22e71776c9a9cbbe18f4afd77dc6d868f983867 100644 (file)
@@ -1038,6 +1038,7 @@ ngx_http_core_try_files_phase(ngx_http_request_t *r,
     ssize_t                       reserve, allocated;
     u_char                       *p, *name;
     ngx_str_t                     path;
+    ngx_uint_t                    test_dir;
     ngx_http_try_file_t          *tf;
     ngx_open_file_info_t          of;
     ngx_http_script_code_pt       code;
@@ -1133,6 +1134,8 @@ ngx_http_core_try_files_phase(ngx_http_request_t *r,
             }
         }
 
+        test_dir = tf->test_dir;
+
         tf++;
 
         ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
@@ -1172,7 +1175,7 @@ ngx_http_core_try_files_phase(ngx_http_request_t *r,
             continue;
         }
 
-        if (!of.is_file) {
+        if (of.is_dir && !test_dir) {
             continue;
         }
 
@@ -3853,6 +3856,11 @@ ngx_http_core_try_files(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 
         tf[i].name = value[i + 1];
 
+        if (tf[i].name.data[tf[i].name.len - 1] == '/') {
+            tf[i].test_dir = 1;
+            tf[i].name.len--;
+        }
+
         n = ngx_http_script_variables_count(&tf[i].name);
 
         if (n) {
index 5be856123950d8fcf878db8b4370081e86d6cdc9..46acb2b4fe1dbc86385e3c6a90c5f76dd7dd3e3d 100644 (file)
@@ -245,6 +245,7 @@ typedef struct {
     ngx_array_t               *lengths;
     ngx_array_t               *values;
     ngx_str_t                  name;
+    ngx_uint_t                 test_dir;   /* unsigned  test_dir:1; */
 } ngx_http_try_file_t;