首页 > Nginx $upstream_http_content_type 正则问题

Nginx $upstream_http_content_type 正则问题

我通过 nginx 的 $upstream_http_content_type 判断类型是否是图片,代码如下:

add_header X-Content-Type $upstream_http_content_type;

if ($upstream_http_content_type ~* ^image/(jpg|jpeg|pjpeg|png|x-png|gif|bmp|x-icon|webp|svg\+xml)) {
    return 301;
}

可结果是 X-Content-Type 倒是有了,却没有 301 跳转?

理论上应该酱紫啊:

求解,如何弄?


没细看哈 如果真是正则的问题 那就是你image后的斜线没有转义^image\/(jpg|jpeg|pjpeg|png|x-png|gif|bmp|x-icon|webp|svg\+xml)

【热门文章】
【热门文章】