2013-02-10 56 views
4

我試圖解決鉻警告:資源解釋爲字體,但使用MIME類型text/html轉移不會解決

資源解釋爲字體,但MIME類型文本轉/ HTML

,我想它是禁止正確加載我的字體。我使用此代碼到CSS:

@font-face { 
    font-family: 'stereofidelic'; 
    src: url('/css/fonts/stereofidelic.eot'); /* IE9 Compat Modes */ 
    src: url('/css/fonts/stereofidelic.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ 
     url('/css/fonts/stereofidelic.woff') format('woff'), /* Modern Browsers */ 
     url('/css/fonts/stereofidelic.ttf') format('truetype'), /* Safari, Android, iOS */ 
     url('/css/fonts/stereofidelic.svg#svgFontName') format('svg'); /* Legacy iOS */ 
    } 
@font-face { 
    font-family: 'bebasneue'; 
    src: url('/css/fonts/BebasNeue.eot'); /* IE9 Compat Modes */ 
    src: url('/css/fonts/BebasNeue.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ 
     url('/css/fonts/BebasNeue.woff') format('woff'), /* Modern Browsers */ 
     url('/css/fonts/BebasNeue.ttf') format('truetype'), /* Safari, Android, iOS */ 
     url('/css/fonts/BebasNeue.svg#svgFontName') format('svg'); /* Legacy iOS */ 
    } 
@font-face { 
    font-family: 'karamuruh'; 
    src: url('/css/fonts/karamuruh.eot'); /* IE9 Compat Modes */ 
    src: url('/css/fonts/karamuruh.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ 
     url('/css/fonts/karamuruh.woff') format('woff'), /* Modern Browsers */ 
     url('/css/fontsh/karamuruh.ttf') format('truetype'), /* Safari, Android, iOS */ 
     url('/css/fonts/karamuruh.svg#svgFontName') format('svg'); /* Legacy iOS */ 
    } 
@font-face { 
    font-family: 'comicnotesmooth'; 
    src: url('/css/fonts/comicnotesmooth.eot'); /* IE9 Compat Modes */ 
    src: url('/css/fonts/comicnotesmooth.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ 
     url('/css/fonts/comicnotesmooth.woff') format('woff'), /* Modern Browsers */ 
     url('/css/fonts/comicnotesmooth.ttf') format('truetype'), /* Safari, Android, iOS */ 
     url('/css/fonts/comicnotesmooth.svg#svgFontName') format('svg'); /* Legacy iOS */ 
    } 
@font-face { 
    font-family: 'singlesleeve'; 
    src: url('/css/fonts/singlesleeve.eot'); /* IE9 Compat Modes */ 
    src: url('/css/fonts/singlesleeve.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ 
     url('/css/fonts/singlesleeve.woff') format('woff'), /* Modern Browsers */ 
     url('/css/fonts/singlesleeve.ttf') format('truetype'), /* Safari, Android, iOS */ 
     url('/css/fonts/singlesleeve.svg#svgFontName') format('svg'); /* Legacy iOS */ 
    }   
@font-face { 
    font-family: 'TravelingTypewriter'; 
    src: url('/css/fonts/TravelingTypewriter.eot'); /* IE9 Compat Modes */ 
    src: url('/css/fonts/TravelingTypewriter.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ 
     url('/css/fonts/TravelingTypewriter.woff') format('woff'), /* Modern Browsers */ 
     url('/css/fonts/TravelingTypewriter.ttf') format('truetype'), /* Safari, Android, iOS */ 
     url('/css/fonts/TravelingTypewriter.svg#svgFontName') format('svg'); /* Legacy iOS */ 
    } 

我tryed任何一種指令添加到我的.htaccess,谷歌上搜索,我發現了很多被添加到.htaccess中的以下解決方案:

AddType application/vnd.ms-fontobject .eot 
AddType application/octet-stream .otf .ttf 
AddType font/otf .otf 
AddType font/opentype .woff 

但我'還是從Chrome中得到同樣的警告:

Resource interpreted as Font but transferred with MIME type text/html: "http://mydomain/css/fonts/TravelingTypewriter.woff". index.php:195 
Resource interpreted as Font but transferred with MIME type text/html: "http://mydomain/css/fonts/BebasNeue.woff". index.php:195 
Resource interpreted as Font but transferred with MIME type text/html: "http://mydomain/css/fonts/TravelingTypewriter.ttf". index.php:195 
Resource interpreted as Font but transferred with MIME type text/html: "http://mydomain/css/fonts/BebasNeue.ttf". index.php:195 
Resource interpreted as Font but transferred with MIME type text/html: "http://mydomain/css/fonts/TravelingTypewriter.svg". index.php:195 
Resource interpreted as Font but transferred with MIME type text/html: "http://mydomain/css/fonts/BebasNeue.svg". index.php:195 

在我的本地Web服務器一切工作正常,我不需要任何將AddType指令進入的.htaccess。

這是24小時的谷歌+嘗試解決方案建議在stackoverflow.com上,但沒有運氣。

任何幫助?

+0

部分解決:將規則重寫爲.htaccess做出了一個令人討厭的行爲,我改變了一些規則,現在字體可以在Chrome中使用,但在Firefox中不能使用 – Alessandro 2013-02-11 17:22:51

回答

1

如果你有國防部重寫你應該設置規則如下:

RewriteEngine On 
RewriteRule !(\.ico\.gif|\.png|\.jpe?g|\.css|\.js|\.php|\.eot|\.svg|\.ttf|\.woff|\.otf|^public/.*)$ index.php [nocase,last] 

我使用Apache。

相關問題