问题
I've a big problem after I add this line into my htaccess:
RewriteRule ([a-z]+)/ index.php?p=$1 [L]
I have error like that:
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".
I think that the problem is that my htaccess try to redirect all the link media/... to index.php?p= ...
So how to fix it please
回答1:
As you already assumed, your rule matches your media/... You probably want your regex to end on $:
RewriteRule ([a-z]+)/$ index.php?p=$1 [L]
Edit: Also you might be interested in loading public libraries like boostrap from a CDN for better performance:
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
回答2:
You should add something like this before your RewriteRule:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
This will make sure that the RewriteRule will only trigger if the file does not exist (so the rewriterule will no longer trigger for the css files for example).
来源:https://stackoverflow.com/questions/26233162/htaccess-resource-interpreted-as-script-but-transferred-with-mime-type-text-htm