2015-08-25 23 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; 
} 

注意,不要使用“最后”有文件