Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using svgz in html server

Tags:

svg

svgz

I use chrome to visualize a svg file which I put on a server, that works fine. Here's the dead simple html for it:

<a href="test.svg">svg</a>

However, when I try to use svgz instead, it doesn't work. Here's the code I use:

<a href="test.svgz">svgz</a>

Here the error:

This page contains the following errors: error on line 1 at column 1: Encoding error Below is a rendering of the page up to the first error.

Looks to me that the browser doesn't decompress the file first. Any idea how can I make this (much smaller) svgz file to display nicely on my browser?


2 Answers

I had to add a .htaccess in the web folder root with the following content:

AddType image/svg+xml svg
AddType image/svg+xml svgz
AddEncoding x-gzip .svgz

From those 2 links here and here

The info on this page solve my problem with IIS http://forums.iis.net/t/1175276.aspx/1

<system.webServer>
  <rewrite>
    <outboundRules>
        <rule name="Rewrite SVGZ header" preCondition="IsSVGZ" stopProcessing="true">
            <match serverVariable="RESPONSE_Content_Encoding" pattern=".*" />
            <action type="Rewrite" value="gzip" />
        </rule>
        <preConditions>
            <preCondition name="IsSVGZ">
                <add input="{PATH_INFO}" pattern="\.svgz$" />
            </preCondition>
        </preConditions>
    </outboundRules>
  </rewrite>
  <staticContent>
    <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
    <mimeMap fileExtension=".svgz" mimeType="image/svg+xml" />
  </staticContent>
</system.webServer>
like image 35
Riga Avatar answered Mar 21 '26 14:03

Riga



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!