Виртуальные директори ЧПУ

Igor Sysoev is at rambler-co.ru
Tue Aug 1 09:35:22 MSD 2006


On Tue, 1 Aug 2006 admin at it-2.ru wrote:

> Доброго времени суток ,первый раз работаю с ngnix, хочу переехать с Апача2 на ваш ngnix
> но у меня проблемка на некторых виртуальных хостах используеться
> mod_rewrite(виртуальные директории) в апаче конфиг выглядит примерно так%
> RewriteEngine on
> Options +FollowSymlinks +Multiviews
> RewriteBase /
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteCond %{REQUEST_FILENAME} !-d
> RewriteRule ^(.*)$ ./index.php [L,QSA]
> Не могли бы вы мне помоч в настройке ngnix
> для использования виртуальных директорий на виртуальном хосте.....
> Почитав список рассылки смог сделать только до такого вида
>                if (!-f $request_filename){
>                rewrite ^(.*)$ /index.html last;
>                }
>                опция !-d не работает ругается...

Прилагаемый патч добавляет -d и !-d. Но в данном случае не поможет,
так как конструкция вида:

     if (!-f $request_filename && !-d $request_filename) {

не поддерживается.


Игорь Сысоев
http://sysoev.ru
-------------- next part --------------
--- src/http/modules/ngx_http_rewrite_module.c	Thu Jul 13 13:37:39 2006
+++ src/http/modules/ngx_http_rewrite_module.c	Tue Aug  1 09:23:27 2006
@@ -824,6 +824,18 @@
             }
         }
 
+        if (p[1] == 'd') {
+            fop->op = ngx_http_script_file_dir;
+            return NGX_CONF_OK;
+        }
+
+        if (p[0] == '!') {
+            if (p[2] == 'd') {
+                fop->op = ngx_http_script_file_not_dir;
+                return NGX_CONF_OK;
+            }
+        }
+
         ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                            "invalid condition \"%V\"", &value[cur]);
         return NGX_CONF_ERROR;
--- src/http/ngx_http_script.c	Wed May 31 17:27:59 2006
+++ src/http/ngx_http_script.c	Tue Aug  1 09:21:35 2006
@@ -961,8 +961,10 @@
 
         switch (code->op) {
         case ngx_http_script_file_plain:
+        case ngx_http_script_file_dir:
              goto false;
         case ngx_http_script_file_not_plain:
+        case ngx_http_script_file_not_dir:
              goto true;
         }
 
@@ -978,6 +980,18 @@
 
     case ngx_http_script_file_not_plain:
         if (ngx_is_file(&fi)) {
+            goto false;
+        }
+        goto true;
+
+    case ngx_http_script_file_dir:
+        if (ngx_is_dir(&fi)) {
+             goto true;
+        }
+        goto false;
+
+    case ngx_http_script_file_not_dir:
+        if (ngx_is_dir(&fi)) {
             goto false;
         }
         goto true;
--- src/http/ngx_http_script.h	Mon Apr 24 15:50:23 2006
+++ src/http/ngx_http_script.h	Tue Aug  1 09:20:08 2006
@@ -140,7 +140,9 @@
 
 typedef enum {
     ngx_http_script_file_plain = 0,
-    ngx_http_script_file_not_plain
+    ngx_http_script_file_not_plain,
+    ngx_http_script_file_dir,
+    ngx_http_script_file_not_dir
 } ngx_http_script_file_op_e;
 
 


More information about the nginx-ru mailing list