【问题标题】:Nginx excluding directory from redirect rulesNginx 从重定向规则中排除目录
【发布时间】:2015-08-25 08:31:24
【问题描述】:

我在 Nginx 中有以下 .conf

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
    }
}

我在这里要做的是从所有 EzPublish 重写规则中排除 /front/ 文件夹。但是,这不仅不起作用,甚至在尝试加载此文件时也会给我一个错误:

"nginx: [emerg] "include" 指令在 /etc/nginx/conf.d/staging-preview.conf:51 中是不允许的 nginx:配置文件 /etc/nginx/nginx.conf 测试失败”

我发现几乎没有使用“if”,请参阅http://wiki.nginx.org/IfIsEvil,但我不明白我应该做什么。

【问题讨论】:

    标签: nginx


    【解决方案1】:

    只需创建单独的位置块并包含/排除您想要的任何内容。您可以根据需要在每个中重复“包含”

    例如:

    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;
    }
    

    请注意,您不要使用“last”来包含文件

    【讨论】:

      猜你喜欢
      • 2015-08-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-22
      • 2017-07-10
      • 2014-01-29
      • 2010-12-23
      相关资源
      最近更新 更多