2015-09-02 23 views
0

我目前正在使用一個相同的代碼庫在許多網站上設置並行加載,並且我遇到了未在樣式中加載字體的問題。並行加載樣式的字體不加載

這裏是它是如何設置:

的.htaccess:

# Images/Styles/Scripts rewrites 
RewriteCond %{HTTP_HOST} ^(images\.)?([^.]+) [OR] 
RewriteCond %{HTTP_HOST} ^(styles\.)?([^.]+) [OR] 
RewriteCond %{HTTP_HOST} ^(scripts\.)?([^.]+) 
RewriteRule .* - [E=DOMAIN_SEGMENT:%2] 

在頭

<link type="text/css" rel="stylesheet" href="http://styles.test.com/font-awesome/css/font-awesome.min.css"> 

test.com由當前站點的實際域替換。

在樣式表

@font-face { 
    font-family:'Aller'; 
    src: url('/fonts/aller_rg-webfont.eot'); 
    src: url('/fonts/aller_rg-webfont.eot?#iefix') format('embedded-opentype'), 
     url('/fonts/aller_rg-webfont.woff') format('woff'), 
     url('/fonts/aller_rg-webfont.ttf') format('truetype'), 
     url('/fonts/aller_rg-webfont.svg#Aller') format('svg'); 
    font-weight: normal;font-style: normal; 
} 

使用相同的代碼庫很多網站,這是不可能硬設置了CSS中的字體域。 所有字體在並行更改之前加載正常。

樣式表的其餘部分正在正確加載。

謝謝

回答

0

我發現這個問題,字體試圖從styles.test.com/fonts/aller_rg-webfont.eot加載,因此不加載。

一個解決方案是使用這在我的.htaccess文件

<FilesMatch "\.(ttf|ttc|otf|eot|woff)$"> 
    <IfModule mod_headers.c> 
     Header set Access-Control-Allow-Origin "*" 
    </IfModule> 
</FilesMatch> 
0

將此

@font-face { 
    font-family:'Aller'; 
    src: url('fonts/aller_rg-webfont.eot'); 
    src: url('fonts/aller_rg-webfont.eot?#iefix') format('embedded-opentype'), 
     url('fonts/aller_rg-webfont.woff') format('woff'), 
     url('fonts/aller_rg-webfont.ttf') format('truetype'), 
     url('fonts/aller_rg-webfont.svg#Aller') format('svg'); 
    font-weight: normal;font-style: normal; 
}