title: Set Apache headers conditionally
body: <p>I'm working with an apache server, and I'd like to add headers conditionally.</p>
  
  <p>If the URI matches a certain regex, I'd like to add the header <code>Access-Control-Allow-Origin: *</code>. What is a good way to do this?</p>
  
  <p>What I've tried so far:</p>
  
  <ol>
  <li><p>I added code called by the request handler, using <code>apr_table_add(rq-&gt;headers_out, "Access-Control-Allow-Origin", "*")</code>. But it seems like Apache strips the header before sending the response whenever the header <code>Content-Type: application/x-javascript</code> is also set. Is this the wrong way to do it? Why would Apache strip the header?</p></li>
  <li><p>I've heard mod_headers suggested. Does mod_headers have the capability to place headers based on regex matching with the request URI?</p></li>
  </ol>