2014-10-07 51 views
3

我有一個很大的問題後,我加入這行到我的htaccess:的.htaccess資源解釋爲腳本,但使用MIME類型text/html轉移

RewriteRule ([a-z]+)/ index.php?p=$1 [L] 

我有錯誤這樣的:

Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost/media/css/lvnr.min.css". 
Resource interpreted as Script but transferred with MIME type text/html: "http://localhost/media/js/bootstrap.min.js". 

我覺得現在的問題是,我的htaccess的嘗試重定向所有鏈接媒體/ ...到index.php?p = ...

那麼如何解決它,請

回答

2

正如你已經假定,你的規則匹配的媒體/ ... 你可能希望你的正則表達式來結束上$:

RewriteRule ([a-z]+)/$ index.php?p=$1 [L] 

編輯:您可能也有興趣從加載公共圖書館一樣的自舉CDN獲得更好的性能:

<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script> 
+0

非常感謝您的回答,它完美的工作 – Splinteer 2014-10-07 09:54:27

0

您應該將重寫規則前加上這樣的事情:

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

這將確保只有在文件不存在時纔會觸發RewriteRule(因此重寫程序不會再爲css文件觸發)。

相關問題