Apache之.htaccess文件配置允许跨域

okgoes 2023-05-09 13:07:14
Categories: Tags:

设置允许跨域头

1
Header set Access-Control-Allow-Origin 允许的请求地址

设置域名访问

1
2
3
4
5
6
7
8
9
10
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#-判断规则,若有多个域名则写多条.(除了以下域名,其他均不允许访问)
rewritecond %{http_host}  !^tesy.com$ [nc]
#rewritecond %{http_host} !^testa1.pw$ [nc]
#rewritecond %{http_host} !^testa2.pw$ [nc]
#-禁止规则
rewriterule ^.* - [F,L]
</IfModule>