CORS with php (Wordpress)
<p>I have relaunched my website with Wordpress.
Unfortunately, a couple of fonts are not being displayed neither in Chrome nor Firefox nor IE. I get the following error: </p>

<blockquote>
  <p><em>Access to Font at 'MY WORDPRESS FONTS URL' from origin '<a href="http://w8qb4xj6s.homepage.t-online.de" rel="noreferrer">http://w8qb4xj6s.homepage.t-online.de</a>' has been blocked by CORS
  policy: No 'Access-Control-Allow-Origin' header is present on the
  requested resource. Origin '<a href="http://www.obstgut-auf-der-heide.de" rel="noreferrer">http://www.obstgut-auf-der-heide.de</a>' is
  therefore not allowed access.</em></p>
</blockquote>

<p>This is probably because I've installed Wordpress in a subdirectory, but then "moved" it so the root by copying the index.php to the root (I want the new website to be displayed when requesting the home URL). </p>

<p>In order to fix the missing fonts, I've tried adding either of the following code to header.php and wp-blog-header.php:</p>

<pre><code>header("Access-Control-Allow-Origin: *");
</code></pre>

<hr>

<p>or</p>

<pre><code>Header set Access-Control-Allow-Origin: *
Header set Access-Control-Allow-Headers: Content-Type, Depth, 
    User-Agent, X-File-Size, X-Requested-With, If-Modified-Since, X-File-   
Name, Cache-Control
Header set Access-Control-Allow-Credentials: true
Header set Access-Control-Allow-Methods: OPTIONS, GET, POST
</code></pre>

<hr>

<p>or</p>

<pre><code>var invocation = new XMLHttpRequest();
var url = 'http://www.obstgut-auf-der-heide.de/';

function callOtherDomain(){
  if(invocation) {
    invocation.open('GET', url, true);
    invocation.withCredentials = true;
    invocation.onreadystatechange = handler;
    invocation.send(); 
  }
}
</code></pre>

<hr>

<p>I've also replaced the "*" by the home-URL. Nothing worked. I'm very new to this whole matter and don't know much about php and stuff. But maybe one of you have any idea what else I could try to fix this?? I'd be super grateful!!!!</p>

<p>Thanks, Elena </p>