在 .htaccess 中,我将其如下所示。但我不断收到错误。
从源“https://...”访问位于“https:...”的 XMLHttpRequest 已被 CORS 阻止 策略:上不存在“Access-Control-Allow-Origin”标头 请求的资源。
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Origin "PUT, POST, DELETE, GET, OPTIONS"
Header set Access-Control-Allow-Origin "Accept, Authorization, Content-Type"
RewriteEngine On
Options All -Indexes
# ROUTER WWW Redirect.
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# ROUTER HTTPS Redirect
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# ROUTER URL Rewrite
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php?route=/$1 [L,QSA] Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
您只能有一个“Allow origin”标头,因此最后一个标头将被解释。