Working with SVG images on websites

To make SVG work, both the browser and the server need to support it:

Browser support

  • Firefox 3 does not natively support it
  • IE9 does

Server support

Apache needs the following settings, either in httpd.conf or .htaccess:

AddType image/svg+xml svg svgz
AddEncoding gzip svgz

Supplying different images for unsupported browsers

If you have similarly-named bitmap images that can be used instead for browsers that don’t support SVG, add to httpd.conf or .htaccess:

RewriteEngine on 
RewriteCond %{HTTP_USER_AGENT} Firefox/3.* 
RewriteRule ^(.*).svg$ $1.png [L]

This example detects Firefox 3 and replaces any SVG file with a PNG file of the same name.

This entry was posted in Other, Web development. Bookmark the permalink.

Leave a comment