SVG images are not displayed on certain web servers

I am having problems displaying .svg images in my html files on specific servers. This is confusing to me because I thought the browser was dictated by whether svg images were displayed, but the browser remains the same. I use the following line to display them:

<img src='path/to/image.svg' alt='image' /> 

On one RHEL6 server it displays, on another RHEL5 server it will not. Version httpd: 2.2.15-9.el6 and 2.2.3-53.el5 respectively. The web browser has remained consistent with Google Chrome 12.0.742.122. Is there something between the servers that will determine if the svg image will be displayed?

Error logs do not report anything, access logs give .svg files the status of 200 and 304.

+7
source share
3 answers

An SVG image should be processed with the MIME type image / svg + xml, so I would recommend checking this out first. One way to check the type of MIME used is to use wget to get the image. Here is an example of wget output. Notice where it displays the MIME type:

 jacob@jacob-laptop :~/tmp$ wget http://croczilla.com/bits_and_pieces/svg/samples/butterfly/butterfly.svg --2011-07-25 11:32:04-- http://croczilla.com/bits_and_pieces/svg/samples/butterfly/butterfly.svg Resolving croczilla.com... 77.92.68.237 Connecting to croczilla.com|77.92.68.237|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 31187 (30K) [image/svg+xml] Saving to: `butterfly.svg' 100%[====================================================================>] 31,187 84.5K/s in 0.4s 

If the MIME type is image / svg + xml in both cases, then I would distinguish between the contents of both documents to see if there are differences between them.

In addition, although this does not answer your question, you should also be aware that not all browsers support the img HTML tag for rendering SVG. The reason for this is that, as a rule, img tags used less security than object or embed tags. You can read here for more information on this: Reliable detection <img> tag support for SVG

+9
source

jbeard4 the answer is right, but I would like to supplement it: to fix, you need to make your server for SVG images as image/svg+xml . In Apache, you can do this by adding these two lines to .htaccess :

 AddType image/svg+xml svg svgz AddEncoding gzip svgz 

Via http://kaioa.com/node/45

+2
source

Insert apache parameter into this

 `<filesMatch "\.(svg|svgz)$"> FileETag None <ifModule mod_headers.c> Header set Content-type "image/svg+xml" </ifModule> </filesMatch>` 

before the line <Directory "/LocalServer/cgi-bin">

0
source

All Articles