Useful Information Note

.htaccess解决跨域访问资源问题


<IfModule mod_headers.c>
   Header add Access-Control-Allow-Origin: *
</IfModule>

<IfModule mod_headers.c>
   Header add Access-Control-Allow-Origin: "http://www.domain.com"
</IfModule>

<IfModule mod_headers.c>
   SetEnvIf Origin "http(s)?://(www.)?(domain1.com|domain2.com)$" AccessControlAllowOrigin=$0$1
   Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
</IfModule>


或者
<FilesMatch "\.(ttf|otf|eot|woff|woff2)$">
 <IfModule mod_headers.c>
   SetEnvIf Origin "http(s)?(://)?(www.)?(douzhenjiang.com|douzhenjiang.cn|crogram.com)$" AccessControlAllowOrigin=$0$1
   #Header set Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
   Header set Access-Control-Allow-Origin "*" env=AccessControlAllowOrigin
 </IfModule>
</FilesMatch>



上一篇:Apache 配置中的指令、值内容均是不区分大小写
下一篇:.htaccess http访问跳转至https
Apache