.htaccess Resource is interpreted as Script, but passed with MIME / html text

I have a big problem after adding this line to my htaccess:

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

      

I have an error:

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 the problem is my htaccess trying to redirect all media links / ... to index.php? p = ...

So how to fix this please

+3


source to share


2 answers


As you might have guessed, your rule matches your media / ... You probably want your regex to end with $:

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

      



Edit: Also you may need to download public libraries like boostrap from CDN for better performance:

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

      

+2


source


You should add something like this before the RewriteRule:

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

      



This will cause the RewriteRule to only run if the file does not exist (so the rewrite will no longer run for css files, for example).

0


source







All Articles