Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Windows 綜合教學 >> 關於 Windows

IIS7 環境下設定 SVG/WOFF/WOFF2 字型 MIME 類型讓字體正常顯示

編輯:關於 Windows

WordPress 遷移至 Windows Azure (IIS7) 後 WOFF 字體 404,原因為缺少 MIME 類型對應。透過網站根目錄 web.config 加入 <staticContent> 區塊設定:

<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
<mimeMap fileExtension=".woff2" mimeType="application/x-font-woff" />

完整 web.config 結構範例:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <staticContent>
      <mimeMap fileExtension=".svg" mimeType="image/svg+xml"/>
      <mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
      <mimeMap fileExtension=".woff2" mimeType="application/x-font-woff" />
    </staticContent>
    <rewrite>...</rewrite>
  </system.webServer>
</configuration>

儲存刷新頁面即可正常載入字體。IIS6 設定法請參考相關文章。

Copyright © Windows教程網 All Rights Reserved