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?

link|improve this question

feedback

2 Answers

up vote 3 down vote accepted

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!

link|improve this answer
Perfect, thanks! – andrewtweber Dec 12 '11 at 1:49
feedback

And, an alternate option:

SetEnvIf Request_URI "\.ttf$" change_header
Header set Access-Control-Allow-Origin "*" env=change_header
link|improve this answer
Is there any reason this would be preferred to the <Files> method? – andrewtweber Dec 12 '11 at 1:50
feedback

Your Answer

 
or
required, but never shown

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