2

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?

8

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

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

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

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

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? – andrewtweber Dec 12 '11 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.