如果uri包含路径,请不要重定向

时间:2016-12-09 18:31:02

标签: nginx nginx-location

我将流量重定向到我的网站,对于某些国家/地区:

if ($http_cf_ipcountry != "UK") {
    return 301 https://int.xyz.com;
}

现在,如果请求uri指向特定位置,我如何授予用户访问网站的权限?例如跟随但在nginx中的东西:

if ($http_cf_ipcountry != "UK" && !contains($uri, "/resource/image/")) {
    return 301 https://int.xyz.com;
}

1 个答案:

答案 0 :(得分:0)

您可以使用location块:

location /resource/image/ {
    ...
}
location / {
    if ($http_cf_ipcountry != "UK") {
        return 301 https://int.xyz.com;
    }
    ...
}

有关详细信息,请参阅this document