首頁  >  問答  >  主體

正規表示式 - 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 天前841

全部回覆(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
  • 取消回覆