I have a problem with CSS files being incorrectly marked text/html by Apache. The file type is mismatched in the browser, and is ignored causing display failures.
I'm using Apache 2.2.3 on a RHEL 5 server.
I've tried adding this to httpd.conf
and reloading config with service httpd reload
:
AddType text/css .css
No change as seen by the browser. My css file is still showing text/html
(even when I use php curl to probe the mime type.. it makes no difference, the server is sending out a text/html
file)
I then commented out the following lines from httpd.conf
, to make sure something screwy wasn't going on with magic:
LoadModule mime_magic_module modules/mod_mime_magic.so
<IfModule mod_mime_magic.c>
MIMEMagicFile /usr/share/magic.mime
MIMEMagicFile conf/magic
</IfModule>
Once those were set aside, I saved & reloaded the config. No change. The .css files are still coming across as text/html
.
Virtualhost standard config:
<VirtualHost 1.2.3.4:80>
ServerName my.site.com
ServerAdmin [email protected]
DocumentRoot /var/www/mysite/
# Log info redacted #
</VirtualHost>
Virtualhost SSL config:
<VirtualHost 1.2.3.4:443>
ServerName my.site.com
ServerAdmin [email protected]
DocumentRoot /var/www/mysite/
# Log info redacted #
# SSL Certificate config redacted #
<Files ~ "\.(cgi|shtml|phtml|php3?)$">
SSLOptions +StdEnvVars
</Files>
SetEnvIf User-Agent ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
CustomLog logs/ssl_request_log \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>
Here's what I'm getting from shell:
[boxor]# file --mime install.css
install.css: text/x-c; charset=us-ascii
Here's what I'm getting from php:
$file = 'https://my.site.com/traq/install/install.css';
echo mime_content_type($file);
$file = $_SERVER['DOCUMENT_ROOT] . '/traq/install/install.css';
echo mime_content_type($file);
returns:
text/html; charset=UTF-8
text/plain
Wrong on all three counts.
Here is a line from my apache access log (with Content-type added):
1.2.3.4 - - [10/Oct/2012:08:32:38 -0400] "GET /traq/install//install.css HTTP/1.1" 200 2600 "http://my.site.com/traq/install/" "text/html" "Mozilla/5.0 blahblah Firefox/15.0.1"
A non-existent css file included on the same page is also returned as "text/html":
1.2.3.4 - - [10/Oct/2012:09:11:11 -0400] "GET /traq/install/idontexist.css HTTP/1.1" 200 2600 "http://my.site.com/traq/install/" "text/html" "Mozilla/5.0 blahblah Firefox/15.0.1"
So... What am I overlooking here?
I finally discovered the problem. The Traq installation view file, install/views/layout.php included a doctype at the top of this file:
Removing the top line
<!doctype html>
solved the problem. The included css files are now seen as acutal css files, and the styles finally appear.