首页  >  问答  >  正文

正则表达式 - 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 跳转?

理论上应该酱紫啊:

求解,如何弄?

世界只因有你世界只因有你2713 天前838

全部回复(1)我来回复

  • ringa_lee

    ringa_lee2017-05-16 17:26:03

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

    回复
    0
  • 取消回复