dsgrgaz321973284 2016-03-17 15:33
浏览 169

Wordpress中的CORS标头

I'm having some difficulty with CORS headers not giving me access to fonts in my Wordpress site.

This is the error I get in the console:

*

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://fonts.gstatic.com/s/raleway/v10/0dTEPzkLWceF7z0koJaX1A.woff2. (Reason: CORS header 'Access-Control-Allow-Origin' missing)

.*

I've tried the following but to no avail:

  • Amending my htaccess. file. Here it is:

    Switch rewrite engine off in case this was installed under HostPay.

    RewriteEngine Off

    AddHandler application/x-httpd-php53 .php .php5

    DirectoryIndex index.cgi index.php

    BEGIN WordPress

    RewriteEngine On Header set Access-Control-Allow-Origin "" Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type" Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS" Header set Access-Control-Allow-Origin "" RewriteBase / RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]

    END WordPress

    • Downloading the WP-CORS plugin, which seems to be what I need but the bloody 'Settings' tab doesn't appear!

    • Adding some php into the top of my header.php file, but that doesn't seem to do anything either.

The sit eis hosted on 123-reg so I don't have access to Apache, so sudo a2enmod headers isn't an option either.

Any help would be really appreciated

  • 写回答

1条回答 默认 最新

  • dongluan0020 2018-10-30 19:43
    关注

    The server that serves the file gets to chose who gets to request the file. The file you're attempting to request is on Google's server as KIMB-technologies said.

    You cannot set CORS for someone else's server. That just wouldn't be nice.

    You can read more about CORS from Mozilla over here.

    评论

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料