Header set Access-Control-Allow-Origin not working with mod_rewrite + mod_jk

Solution 1:

I've successfully used:

SetEnvIf Origin "http(s)?://(domaine1\.com|domain2\.com)$" AccessControlAllowOrigin=$0
Header set Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin

from http://www.cameronstokes.com/2010/12/26/cross-origin-resource-sharing-and-apache-httpd/

Solution 2:

Since it's a redirect, you need "header set always ..." due to some unfortunate Apache internals. As long as you're not editing/overwriting an existing header, "always" is reasonable to just slap in there w/o much worry.