在PHP中设置标题
header("Access-Control-Allow-Origin: https://www.example.com");
header("Access-Control-Allow-Headers: Content-Type, Content-Range, Content-Disposition, Content-Description");
.htaccess中设置的标题
SetEnvIf Origin ^(https?://.+\.(example|gstatic)\.com(?::\d{1,5})?)$ CORS_ALLOW_ORIGIN=$1
Header append Access-Control-Allow-Origin %{CORS_ALLOW_ORIGIN}e env=CORS_ALLOW_ORIGIN
Header set Access-Control-Allow-Headers "origin, x-requested-with, content-type"
Header set Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
Header merge Vary "Origin"
我不想编辑.htaccess文件。 PHP header()函数是否会覆盖。