Skip to content

Instantly share code, notes, and snippets.

@armno
Created February 15, 2013 09:35
Show Gist options
  • Save armno/4959387 to your computer and use it in GitHub Desktop.
Save armno/4959387 to your computer and use it in GitHub Desktop.
Allowing Access-Control-Allow-Origin to multiple domains for Ajax requests
# source: http://www.lowest-common-denominator.com/2010/01/http_access_control_to_multipl.php
# - replace `domain1.com` and `domain2.com`
# - add more domains by separating each domain with a pipe `|`
# - escape dot `.` with a backslash
<IfModule mod_headers.c>
SetEnvIf Origin "^http(s)?://(.+\.)?(domain1\.com|domain2\.com)$" origin_is=$0
Header always set Access-Control-Allow-Origin %{origin_is}e env=origin_is
</IfModule>
@Tusko
Copy link

Tusko commented Nov 20, 2021

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment