Skip to content

Instantly share code, notes, and snippets.

@wheresalice
Created February 25, 2011 15:56
Show Gist options
  • Star 31 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save wheresalice/843983 to your computer and use it in GitHub Desktop.
Save wheresalice/843983 to your computer and use it in GitHub Desktop.
webfont .htaccess rules
# ----------------------------------------------------------------------
# Webfont access
# ----------------------------------------------------------------------
# allow access from all domains for webfonts
# alternatively you could only whitelist
# your subdomains like "sub.domain.com"
<FilesMatch "\.(ttf|otf|eot|woff|font.css)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
# webfont mime types
AddType application/vnd.ms-fontobject eot
AddType font/truetype ttf
AddType font/opentype otf
AddType application/x-font-woff woff
# webfonts and svg:
<IfModule mod_deflate.c>
<FilesMatch "\.(ttf|otf|eot|svg)$" >
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>
@Doggie52
Copy link

For IE10, instead of application/vnd.ms-fontobject, font/eot seems to be what Google Font API uses for the eot mime type.

@mbuskies
Copy link

mbuskies commented Feb 6, 2021

You'll probably never see this but this just totally saved my ass. <3 I've been trying to get webfonts to work on a project for 3 days with no luck ,but this worked like a charm.

@sahildmspl
Copy link

Yes It also worked for me.

@sahildmspl
Copy link

sahildmspl commented Aug 26, 2022

Checks to see if the user is attempting to access a valid file,

# such as an image or css document, if this isn't true it sends the
# request to the front controller, index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\s\S]*)$ index.php/$1 [L,NC,QSA]

can we change this to accept webfonts 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment