Both firefox and chrome are showing that javascript files from my server are served as MIME type text/html. The javascript files have a .js extension.
First, mime_module is installed and active:
apachectl -M | grep mime
mime_magic_module (shared)
mime_module (shared)
Syntax OK
Second, I have this in my conf file:
AddType text/css .css
AddType text/javascript .js
I tried adding this:
<Files "*.js">
ForceType text/javascript
</Files>
and restarted apache, but the javascript files still show as "text/html" in Chrome and Firefox. Nothing shows in error.log and access.log isn't returning anything useful:
1.2.3.4 - - [03/Mar/2015:10:42:00 -0500] "GET /some/dir/js/app-min.js HTTP/1.1" 200 14642
Here are headers on one of the .js files (as seen in Firefox)
Connection: close
Content-Type: text/html; charset=UTF-8
Server: Apache
Strict-Transport-Security: max-age=63072000; includeSubDomains
Transfer-Encoding: chunked
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-Permitted-Cross-Domain-Policies: master-only
X-WebKit-CSP: default-src 'self'
X-XSS-Protection: 1; mode=block
This file shows as type html
in Firefox inspector.
Here's the header of the same file as served by my laptop's apache instance:
Connection: Keep-Alive
Date: Tue, 03 Mar 2015 15:43:52 GMT
Keep-Alive: timeout=5, max=95
Server: Apache/2.4.7 (Ubuntu)
This file shows as type js
in Firefox inspector. Note that the local instance of Apache (2.4) is not responding with Content-Type
.
Why is the main server defying AddType? I've added this to both the httpd.conf and ssl.conf (though my site forces 443). I've restarted apache (no syntax errors).
I had a smilimar issue, some sysadmin add the next directive con conf.modules.d/10-php.conf:
But this set all extencions to that hander, so I change it for:
Issue solved :)
Problem solved. conf.d/php.conf contained these lines:
I changed the first line to
Then saved and restarted Apache. The js & css files now appear with the correct mime type in Firefox/Chrome.
As an aside I tried adding
AddType text/javascript .js
just belowAddType text/html .php
, but the files still showed astext/html
in Inspector. I had to remove .css and .js from AddHandler for the correct mime type to be sent.