snipt

Ctrl+h for KB shortcuts

Text only

Allow Cross-Domain Fonts with CORS

# I had no idea how big of a response I’d have when I first posted about cross-domain fonts. 
# They’re a big, confusing problem for people but HTML5BP also has a solution:

<IfModule mod_headers.c>
    <FilesMatch "\.(eot|otf|ttc|ttf|woff)$">
        Header set Access-Control-Allow-Origin "*"
    </FilesMatch>
</IfModule>

# Fonts are best served off of CDN so now you can do so without issue!
# Serving Fonts from CDN: http://davidwalsh.name/cdn-fonts

http://davidwalsh.name/html5-boilerplate-htaccess
https://snipt.net/embed/3638cbd01bcfbb14e5090f6000e72b5a/
/raw/3638cbd01bcfbb14e5090f6000e72b5a/
3638cbd01bcfbb14e5090f6000e72b5a
text
Text only
13
2019-08-25T11:23:11
True
False
False
/api/public/snipt/100827/
allow-cross-domain-fonts-with-cors
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1"> 1</a> <a href="#L-2"> 2</a> <a href="#L-3"> 3</a> <a href="#L-4"> 4</a> <a href="#L-5"> 5</a> <a href="#L-6"> 6</a> <a href="#L-7"> 7</a> <a href="#L-8"> 8</a> <a href="#L-9"> 9</a> <a href="#L-10">10</a> <a href="#L-11">11</a> <a href="#L-12">12</a> <a href="#L-13">13</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a># I had no idea how big of a response I’d have when I first posted about cross-domain fonts. </span><span id="L-2"><a name="L-2"></a># They’re a big, confusing problem for people but HTML5BP also has a solution: </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a>&lt;IfModule mod_headers.c&gt; </span><span id="L-5"><a name="L-5"></a> &lt;FilesMatch &quot;\.(eot|otf|ttc|ttf|woff)$&quot;&gt; </span><span id="L-6"><a name="L-6"></a> Header set Access-Control-Allow-Origin &quot;*&quot; </span><span id="L-7"><a name="L-7"></a> &lt;/FilesMatch&gt; </span><span id="L-8"><a name="L-8"></a>&lt;/IfModule&gt; </span><span id="L-9"><a name="L-9"></a> </span><span id="L-10"><a name="L-10"></a># Fonts are best served off of CDN so now you can do so without issue! </span><span id="L-11"><a name="L-11"></a># Serving Fonts from CDN: http://davidwalsh.name/cdn-fonts </span><span id="L-12"><a name="L-12"></a> </span><span id="L-13"><a name="L-13"></a>http://davidwalsh.name/html5-boilerplate-htaccess </span></pre></div> </td></tr></table>
htaccess, vhost