相关疑难解决方法(0)

Access-Control-Allow-Origin多个源域?

有没有办法允许多个跨域使用Access-Control-Allow-Origin标头?

我知道了*,但它太开放了.我真的想只允许一些域名.

举个例子,像这样:

Access-Control-Allow-Origin: http://domain1.example, http://domain2.example
Run Code Online (Sandbox Code Playgroud)

我已经尝试过上面的代码,但它似乎不适用于Firefox.

是否可以指定多个域,或者我只坚持一个?

.htaccess http xmlhttprequest cross-domain cors

985
推荐指数
17
解决办法
74万
查看次数

跨域字体问题

请在评论之前阅读所有这些内容.

我目前正在开发一个托管在Amazon Web Services(AWS)上的大型网站.这使我们可以在网站可能承受大量流量的情况下使用可扩展性功能.

最初我们开始将网站代码分离出混合的HTML/PHP/Java等,并在单独的服务器上拥有静态资产.当我第一次尝试在此设置中使用font-face时,我发现Firefox和IE不会加载字体,并且很快发现它是一个跨域问题.有很多种解决方案,包括修改标题以允许访问字体文件.但是,我们使用的存储系统不允许这种类型的标头修改.

为了看看我是否可以让字体在所有浏览器中运行,我将它们和调用它们的CSS文件调用到与网站相同的域中.但是它们似乎仍然没有在Firefox或IE中加载.如果我复制代码并在我的文档中本地运行它,所有浏览器中的一切似乎都很好(因此文件不会被破坏).Firefox肯定会找到这些文件,因为我可以看到它们是通过FireBug加载的.

我检查了所有网址,以确保它们是正确的,并解决它们应该在哪里.

这是我在笑脸黑客中使用的font-face CSS:

@font-face {
    font-family : "AllerRegular";
    src : url('aller_rg-webfont.eot');
    src : local('?'),
          url('aller_rg-webfont.woff') format('woff'), 
          url('aller_rg-webfont.ttf') format('truetype'), 
          url('aller_rg-webfont.svg#webfontooYDBZYS') format('svg');
    font-weight : normal;
    font-style : normal;
}
Run Code Online (Sandbox Code Playgroud)

CSS文件与字体位于同一目录中.

我还在.htaccess文件中设置了MIME类型,该文件与字体位于同一文件夹中.

AddType application/vnd.ms-fontobject .eot
AddType font/truetype .ttf
AddType font/opentype .otf
AddType font/opentype .woff
AddType image/svg+xml .svg .svgz
AddEncoding gzip .svgz
<FilesMatch "\.(ttf|otf|eot|woff|svg)$">
        <IfModule mod_headers.c>
                Header set Access-Control-Allow-Origin "*"
        </IfModule>
</FilesMatch>
Run Code Online (Sandbox Code Playgroud)

如果您有任何想法,请建议.
我已经在网上搜索了几天,但所有解决方案都让我失望了.

html css fonts cross-domain font-face

17
推荐指数
2
解决办法
3万
查看次数

@ font-face无法在Firefox 3.6.14中工作 - WOFF或TTF

@ font-face无法在Firefox 3.6.14中工作 - WOFF或TTF

@font-face {
    font-family: "A-B";
    src: url("fonts/AlexandriaFLF-Bold.woff") format("woff"),
         url("fonts/AlexandriaFLF-Bold.ttf") format("truetype"),
         url("fonts/AlexandriaFLF-Bold.svg#webfontm3eq21Q4") format("svg");
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'A-BI';
    src: url("fonts/AlexandriaFLF-BoldItalic.woff") format("woff"),
         url("fonts/AlexandriaFLF-BoldItalic.ttf") format("truetype"),
         url("fonts/AlexandriaFLF-Bold.svg#webfontszsn4DPI") format("svg");
    font-weight: normal;
    font-style: normal;
}
Run Code Online (Sandbox Code Playgroud)

任何人都可以开导我吗?

css font-face

1
推荐指数
1
解决办法
3682
查看次数

标签 统计

cross-domain ×2

css ×2

font-face ×2

.htaccess ×1

cors ×1

fonts ×1

html ×1

http ×1

xmlhttprequest ×1