I'm trying to use mod_headers to set a header for certain file types. Specifically, I want to set Access-Control-Allow-Origin to "*" for ttf files. Is there a rule I can add to my VirtualHost that will do this for me?

2 Answers 2


You can use the <Files> tag to do this (docs), i.e.:

<Files "*.ttf">
  Header set Access-Control-Allow-Origin "*"

This will restrict the Header to only files ending in .ttf. Hope this helps!

  • 1
    Since this wasn't obvious to me right away, it may help someone else too, make sure to run a2enmod headers. Apr 15, 2019 at 2:29

And, an alternate option:

SetEnvIf Request_URI "\.ttf$" change_header
Header set Access-Control-Allow-Origin "*" env=change_header
  • 2
    Is there any reason this would be preferred to the <Files> method? Dec 12, 2011 at 1:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.