Httpd – Set header for certain file types using Apache2 mod_headers

apache-2.2httpd

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?

Best Answer

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!