title: Access-Control-Allow-Origin for multiple domains, in an easier way
body: <pre><code>header('Access-Control-Allow-Origin: http://splash.example.com');
  header('Access-Control-Allow-Credentials: true');
  </code></pre>
  
  <p>Hello again Stackoverflow!</p>
  
  <p>On my website, I have an ajax file <code>ajax.php</code>, where I need multiple (sub) domains to access it and fire requests. </p>
  
  <p>The problem is that it works for <code>splash.example.com</code> and <code>example.com</code> with the solution posted above, and this in the request:</p>
  
  <pre><code>$.ajax({
      ...
  
      crossDomain: true,
      xhrFields: {
          withCredentials: true
      },
  
      ...
  });
  </code></pre>
  
  <p>But isn't there an easier way? 'Cause right now it isn't working for <code>www.example.com</code>, even with the solution posted above.</p>
  
  <p>I've tried putting this in my htaccess:</p>
  
  <pre><code>&lt;IfModule mod_headers.c&gt;
      Header add Access-Control-Allow-Origin "http://example.com"
      Header add Access-Control-Allow-Origin "http://www.example.com"
      Header add Access-Control-Allow-Origin "http://splash.example.com"
      Header set Access-Control-Allow-Credentials true
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>but this didn't work somehow.</p>
  
  <p>Can you guys help me?</p>