2015-08-25 25 views
0

我在Nginx的Nginx的不包括重定向規則目錄

location/{ 

    if ($uri !~ ^/front/?){ 
     include ez_params.d/ez_rewrite_params last; 
    } 

    include common_auth.conf.inc; 

    location ~ ^/(index|index_(rest|cluster|treemenu_tags))\.php(/|$) { 
    #bunch of rules here 
    } 
} 

以下的.conf什麼我想在這裏做的,是從所有EzPublish重寫規則不含/正面/文件夾。然而,這不僅不能正常工作,甚至給我一個錯誤嘗試加載該文件:

「nginx的:EMERG]‘包括’指令這裏不允許使用在/etc/nginx/conf.d/分期-preview.conf:51 nginx的:配置文件/etc/nginx/nginx.conf測試失敗」

我發現,使用‘如果’是非常不這樣做,看到http://wiki.nginx.org/IfIsEvil,但我不明白我應該做什麼。

回答

3

只需創建個人位置塊幷包括/排除任何你想要的。你可以重複「包括」在每個需要

例如:

location ~ ^/front/? { 
    # Here we only include the common_auth file 
    include common_auth.conf.inc; 
} 
location ~ ^/(index|index_(rest|cluster|treemenu_tags))\.php(/|$) { 
    # Here we also only include the common_auth file 
    include common_auth.conf.inc; 
    .... 
} 
location/{ 
    # Here we also include the common_auth file 
    # As well as the ez_rewrite_params 
    include ez_params.d/ez_rewrite_params; 
    include common_auth.conf.inc; 
} 

注意,不要使用「最後」有文件