Configure the HTTP headers required for the Svgz file for the Web server so that the browser can open the Svgz file

Source: Internet
Author: User

IE8 and IE8 browsers are not SVG-enabled, SVGZ is a compressed format for SVG files, the configuration described in this article is browser-independent, but browsing svgz files is open in other modern browsers such as ie9+ or Firefox,chrome.

3 conditions are required for the browser to display the Svgz file normally:

1, the browser support SVG vector image format

2, the server set the correct response mime-type, that is, the HTTP response header contains Content-type:image/svg+xml

3, the server set the correct response content encoding type, the HTTP response header contains Content-encoding:gzip

This only applies to accessing the Svgz file from the Web server in the form of HTTP, and if you want to open the Svgz file of the local hard drive from the browser, it seems that the current chrome support is not supported by Ie/firefox.

Apache httpd configuration on the server Svgz Method 1: Add the configuration in the. htaccess file. Applies to settings only for a single site.

Add the following 2 lines in the appropriate location in the. htaccess file

AddType image/svg+xml svg svgzaddencoding gzip svgz

Method 2: Add the configuration in the httpd.conf file. Applies to server global, and can also be set for a single host.

Add the following lines in the httpd.conf file

<ifmodule mime_module>    # SVG support    AddType image/svg+xml. svg. svgz addencoding    x-gzip. svgz</ Ifmodule>
Mime-type can also be configured in the Mime.types file, AddType addencoding can also be configured in other. conf files (such as vhosts.conf).
The above is through the Mime_module module configuration, in fact, can also be configured through the Headers_module module, example:

<ifmodule headers_module>    <filesmatch "\.svgz$" >        header set content-type image/svg+xml        Header set content-encoding gzip    </filesmatch></IfModule>
Exactly how to match, where, to see their own needs to be flexible processing.

Example of PHP program dynamic response Svgz file

<?phpheader (' Content-type:image/svg+xml '); header (' Content-encoding:gzip '); Echo file_get_contents (' Test.svgz ') );? >

Configure the HTTP headers required for the Svgz file for the Web server so that the browser can open the Svgz file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.