在 .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=/ [L,QSA]
您只能有一個「Allow origin」標頭,因此最後一個標頭將被解釋。