handle multiple domains with Access-Control-Allow-Origin header in Apache

后端 未结 8 942
独厮守ぢ
独厮守ぢ 2020-12-08 10:17

I want to configure apache for cross-domain access header. I have tried multiple combination as suggested on number of threads on the forum. But its not working for me.

8条回答
  •  被撕碎了的回忆
    2020-12-08 10:35

    For 3 domains, in your .htaccess:

    
        SetEnvIf Origin "http(s)?://(www\.)?(domain1.org|domain2.com|domain3.net)$" AccessControlAllowOrigin=$0$1
        Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
        Header set Access-Control-Allow-Credentials true
    
    

    I've tried this and it works for me. Let me know if it doesn't for you.

提交回复
热议问题