I have a brand new server install, debian, wordpress latest version, all packages up to date. Transferred all content and database across from an old server. The pages load OK, but none of the CSS is applied, and the console output of the browser says "The stylesheet http://blackcountrywoodturners.co.uk/wp-content/themes/misty-lake/style.css?ver=6.2.2 was not loaded because its MIME type, "text/html", is not "text/css"."

The file /etc/mime.types contains the required line "text/css css". I've also added a line to the local .htaccess file to add the type, but no good. Contents of the .htaccess file are:
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
<br> AddType text/css .css

I've already read the various posts on numerous stackexchange sites (and other places), but none of the tips have worked. I seem to remember somebody posting somewhere it had to do with a DOCTYPE directive, but I cannot remember where I saw this.

Any pointers would be highly welcome. The server is not yet on the public internet, but if you have any questions, fire away and I will provide whatever info is needed.

  • 1
    WordPress is not involved in serving CSS files. All it does is add the URL in a <link> tag and the server serves it from that URL. If it's being identified as text/html the issue could be that the file doesn't exist and a 404 HTML page is being served instead. Look at the Network tab of your browsers developer tools to see what's actually being served for that file. Commented Jul 24, 2023 at 10:03
  • Or your htaccess or equivalent config is wrong and you're routing the request through WordPress when you shouldn't be. You should be excluding files that exist from URL rewrites with RewriteCond %{REQUEST_FILENAME} !-f. What do you see if you go to the CSS URL? (It won't load for me)
    – Rup
    Commented Jul 24, 2023 at 10:03
  • Updated the post with .htaccess contents. When I go the CSS URL, it loads as a text file. The network tab shows that the files load, but as html. Commented Jul 24, 2023 at 10:36
  • After jogging my memory, I found a <!DOCTYPE html> tag in the header.php file of the s the theme. When I disable that tag, the styles get applied. The message in the console tab of the browser debugger now states that the file got loaded despite the MIME type mismatch. So, in essence the problem is not fixed, but the browser accepts the files now. I'd still like to fix the issue properly, though. Commented Jul 24, 2023 at 11:01
  • 1
    Your header.php file should have a DOCTYPE declaration. Make sure to put that back. You’re going to needs to share the contents of the CSS file for any further help, although be aware that we’re not really talking about WordPress anymore and this is probably not the place to ask about this problem. Commented Jul 24, 2023 at 11:58

1 Answer 1


OK, so with the help of the comments to my question and some more digging around I have found (what I think is) the correct answer:

The apache config needs to have the headers module enabled ("a2enmod headers") and the mime module ("a2enmod mime") and the .htaccess file needs to have sections as follows:

<IfModule mod_mime.c>

<FilesMatch "[^.]+\.css$">
   Header set Content-Type: "text/css"

<FilesMatch "[^.]+\.js$">
   Header set Content-Type: "text/javascript"


Then restart apache and all errors in the browser go away.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.