Skip to content

Instantly share code, notes, and snippets.

@michaelphipps
Last active May 27, 2018 06:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelphipps/076d9c1a2c744b84563cd6154ea9dda1 to your computer and use it in GitHub Desktop.
Save michaelphipps/076d9c1a2c744b84563cd6154ea9dda1 to your computer and use it in GitHub Desktop.
How to get web fonts working correctly in your server environment.

If you have web fonts on a subdomain seperate to the domain you are calling them, usual advice is to place the following into the .htaccess file for the subdomain

<IfModule mod_headers.c>
  <FilesMatch “.(eot|otf|ttc|ttf|woff|woff2)$”>
    Header set Access-Control-Allow-Origin “*”
  </FilesMatch>  
</IfModule>

If that doesn’t work, it’s likely the header module in apache isn’t enabled. Find out by creating a .htaccess file with just this line.

Header set Access-Control-Allow-Origin “*”

Try to view a web page. If you get errors, most likely the header module isn’t enabled in apache. Enable it from the command line like this

sudo a2enmod headers

then restart apache.

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