Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 4 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!

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

And, an alternate option:

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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