apache - How to serve a gziped font using .htaccess? (no mod gzip or deflate) -
here's list of stuff tried in random order:
addhandler application/x-httpd-php .otf addtype default_mimetype auto_prepend_file = "otf.php" zlib.output_compression = on output_handler = ob_gzhandler header("content-type: application/octet-stream");
even though php files of server gzipped using zlib, replacing .otf extension .php didn't work either.
with .htaccess, this, assuming font file fontfile.otf.gz
, browser request fontfile.otf
rewriteengine on #check browser's accept-encoding, remove force return gzipped 1 rewritecond "%{http:accept-encoding}" "gzip.*deflate|deflate.*gzip" #check file name endswith otf rewritecond %{request_filename} "\.(otf)$" #check existance of .gz file name rewritecond %{request_filename}.gz -s #rewrite .otf.gz rewriterule ^.*$ %{request_uri}.gz [l] #update response header <filesmatch "\.otf\.gz$"> addencoding gzip .gz forcetype "text/plain" </filesmatch>
and if font file , web site cross-domain, need put access-control-allow-origin
, firefox not load font objects cross-domain.
in gecko, web fonts subject same domain restriction (font files must on same domain page using them), unless http access controls used relax restriction.
header set access-control-allow-origin *
Comments
Post a Comment