Firefox & text/css
Greg Rundlett
greg at freephile.com
Thu Dec 16 22:47:00 EST 2004
Jonathan Linowes wrote:
Not exactly on topic, but I know the group will forgive me for wanting
to help, and probably some will even be interested to hear about the issue.
> Hi,
>
> I just learned that some of my sites don't display properly with the
> FireFox browser, and the reason is
>
> Error: The stylesheet http://www.naturalentrepreneur.com/nenh.css was
> not loaded because its MIME type, "text/plain", is not "text/css".
>
I tested your site using Firefox and Mozilla on Linux, and Mozilla and
Internet Explorer on Windows 98SE and they all worked without error.
Firefox is I believe the most standard-compliant browser around, so I
was curious to hear about this problem. Indeed it is the fact that
Firefox *is* standards compliant that reveals a problem with the Apache
webserver (mis)configuration.
> and I found on several forums that the solution is to add a text/css
> mime type to the apache config file (other browsers just figure out
> its a css file). I tried to find apache doc's how to do it, but I
> don't know much about Apache, and I don't want to mess it up. Can you
> help?
Exactly. Even though I saw no visible error message, the server
returned faulty HTTP headers. Here is what you get from your server
upon requesting the CSS file:
http://www.naturalentrepreneur.com/nenh.css
GET /nenh.css HTTP/1.1
Host: www.naturalentrepreneur.com
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5)
Gecko/20041128 Firefox/1.0 (Debian package 1.0-4)
Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
HTTP/1.x 200 OK
Date: Fri, 17 Dec 2004 03:11:36 GMT
Server: Apache/1.3.33 (Unix) PHP/4.3.9 FrontPage/5.0.2.2510
Last-Modified: Tue, 30 Nov 2004 23:21:03 GMT
Etag: "c4dc5e-881-41ad005f"
Accept-Ranges: bytes
Content-Length: 2177
Keep-Alive: timeout=5, max=20
Connection: Keep-Alive
Content-Type: text/plain
This last line of the HTTP headers indicates that Apache is telling the
browser that this file is a plain text file. To have Apache correctly
specify the mime type, you can edit the mime.types file that controls
Apache (if you have access to this file...in a hosted environment you
likely do not).
As root...
find out where yours is located, on my system it is at
/etc/apache/mime.types
locate mime.types
edit this file
vi /etc/mime.types
find the css extension
/css
if you find a css line entry, it will say: 'text/plain css' Put your
cursor on that line and press dd - that is the d key twice, to delete
the line.
dd
Now insert a line to correctly associate the file extension with the
MIME header. Should be: 'text/css css' Press the i key to insert
at the cursor.
i
type 'text/css css' (without the quotes, and add a carriage return)
Save the file
:wq
And restart apache. This command varies by system and version, but
usually 'apachectl -graceful' will work.
/usr/sbin/apachectl graceful
Assuming you do NOT have root access to the machine, but you DO have the
ability to use '.htaccess' files to override the Apache server
settings... You want to create a file named '.htaccess' (Yes the
filename begins with a period, and has no extension.) You can do this
with any real text editor. Dreamweaver should work and it appears that
your site is built using Dreamweaver. In that file you want this line:
AddType text/css css
Save the file and upload it to your server, putting it in the main
'Document Root' of your site. Normally this directory is named
something like 'public_html' or 'www'. .htaccess files are read by
Apache on every request, so you do NOT need to restart your server.
> thanks
You're welcome.
More information about the gnhlug-discuss
mailing list