我已经用Wordpress重新启动了我的网站。不幸的是,Chrome,Firefox和IE中都没有显示两种字体。我收到以下错误:
从起源' http://w8qb4xj6s.homepage.t-online.de '对'MY WORDPRESS FONTS URL'的字体的访问已被CORS策略阻止:请求中不存在'Access-Control-Allow-Origin'标头资源。因此,不允许访问源“ http://www.obstgut-auf-der-heide.de ”。
这可能是因为我已经将Wordpress安装在一个子目录中,然后通过将index.php复制到根目录来“移动”它的根目录(我希望在请求主页URL时显示新网站)。
为了修复丢失的字体,我尝试将以下代码之一添加到header.php和wp-blog-header.php中:
header("Access-Control-Allow-Origin: *");
Run Code Online (Sandbox Code Playgroud)
要么
Header set Access-Control-Allow-Origin: *
Header set Access-Control-Allow-Headers: Content-Type, Depth,
User-Agent, X-File-Size, X-Requested-With, If-Modified-Since, X-File-
Name, Cache-Control
Header set Access-Control-Allow-Credentials: true
Header set Access-Control-Allow-Methods: OPTIONS, GET, POST
Run Code Online (Sandbox Code Playgroud)
要么
var invocation = new XMLHttpRequest();
var url = 'http://www.obstgut-auf-der-heide.de/';
function callOtherDomain(){
if(invocation) {
invocation.open('GET', url, true);
invocation.withCredentials = true;
invocation.onreadystatechange = handler;
invocation.send();
}
}
Run Code Online (Sandbox Code Playgroud)
我还用home-URL替换了“ *”。没事。我对这件事很陌生,对php和其他东西也不了解。但是也许你们中的一个有任何想法我还能尝试解决这个问题吗?我将非常感谢!!!
谢谢,埃琳娜