.htaccess资源解释为脚本,但是以MIMEtypestext / html传输

在将这行添加到我的htaccess后,我遇到了一个很大的问题:

RewriteRule ([az]+)/ 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试图redirect所有的链接媒体/ …到index.php?p = …

那么请如何解决

正如你已经假设,你的规则匹配你的媒体/ …你可能希望你的正则表达式$:

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

编辑:你也可能有兴趣从CDN加载公共图书馆,如更好的表现:

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

你应该在你的RewriteRule之前添加这样的东西:

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

这将确保只有在文件不存在的情况下才会触发RewriteRule(例如,重写过程不再为css文件触发)。