title: PHP Access-Control-Allow-Origin not working
body: <p>I have a subdomain "<strong>x.domain.com</strong>" which then calls files from the static file subdomain "<strong>y.domain.com</strong>".</p>
  
  <p>In my config file I have: </p>
  
  <pre><code>require_once("/var/_BACKEND$/functions/cors.php");
  </code></pre>
  
  <p>This includes the file fine. The contents of "cors.php" is the code contained in the answer for this question:
  <a href="https://stackoverflow.com/questions/8719276/cors-with-php-headers">CORS with php headers</a> (I have tried searching this problem!!)</p>
  
  <p>In the bottom of the config file I also have the code:</p>
  
  <pre><code>if(!function_exists('cors')) die("err"); else cors();
  </code></pre>
  
  <p>Now for some reason, despite the code being exactly as it is above, and the file including fine, I am still receiving the following error from the Browser:</p>
  
  <blockquote>
    <p>XMLHttpRequest cannot load
    <a href="http://y.domain.com/scripts/ajax.php" rel="nofollow noreferrer">http://y.domain.com/scripts/ajax.php</a>. No
    'Access-Control-Allow-Origin' header is present on the requested
    resource. Origin '<a href="http://x.domain.com" rel="nofollow noreferrer">http://x.domain.com</a>' is therefore not allowed
    access.</p>
  </blockquote>
  
  <p>Using a header checker also brings the following results:</p>
  
  <p>The 302 is intentional.</p>
  
  <p><img src="https://i.stack.imgur.com/ZIrwd.png" alt="http headers"></p>
  
  <p>This all appears as it should</p>