Svg/woff/woff2 fonts are displayed normally in IIS7 environment

  

Recently, several WordPress sites from the company moved from AWS to Windows and tossed for a while. A new problem was released today, and the woff font on the website was reported to be 404. After confirming that the file has been uploaded to the correct path, think back to the problem that the font file could not be found in the IIS environment encountered before. It feels that there is no reason to add the MIME type to the font file. Windows Azure is not a virtual host, so it won't give me an IIS for me to configure. I can only think of other ways.

Fortunately, a web.config file was found in the root directory of the website. This is supposed to be the configuration file for the ASP.NET application. Although WordPress uses the PHP language, the management of file types should not involve the scope of the language of the website, as long as the server environment is properly configured.

Open web.config, which is an XML file that already has a MIME type information for the svg file, much like what was previously configured in IIS:

<mimeMap fileExtension= ".svg" mimeType="image/svg+xml"/>Before IIS, the MIME type settings for several font files are as follows:


These two are added to the web.config:

<mimeMap fileExtension=".woff" mimeType="application/x-font-woff" /><mimeMap fileExtension=".woff2" mimeType="application/x-font-woff" /> The tag structure for MIME types in the entire file should look like this:

<?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> After the completion of the refresh the page, woff and other fonts can be loaded smoothly, IIS6 settings, please refer to how to make IIS6 support svg image display

Copyright © Windows knowledge All Rights Reserved