homepage Welcome to WebmasterWorld Guest from 54.167.11.16
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
FireFox: "css not loaded, because it's not text/css"
But it is!
rocknbil




msg:4198894
 11:47 pm on Sep 8, 2010 (gmt 0)

Linux server, have text/css css in mime.types, even went as far as AddType text/css .css in httpd.conf. None of it fixed it.

This is a scheme I use often and have never encountered this. I have this document that needs different links based on browser. Easy enough, put a placeholder for the links, when requested an .htaccess directive rewrites to a script that determines the browser, opens the file, subs out the right links, then does

print "content-type:text/html\n\n";
print "$the_page";

Well enough . . . except I get the "css was not loaded because it's MIME type, "text/html", is not "text/css".

I don't get it. I know my script is overwriting the mime type somehow, but it outputs

<link rel="stylesheet" type="text/css" href="/path/to/style.css" />

As part of the page output, and doesn't even request the style sheet until the script exits. General structure,

/cgi-bin
/httpdocs
/httpdocs/pagedirectory

In .htacess at root (httpdocs)

RewriteRule ^pagedirectory\/([^/]*)\/*(.*) /cgi-bin/page-parser.cgi?d=$1&p=$2 [L]

(Typical structure might be /pagedirectory/layoutdirectory/index.html)

A further verification it's something to do with the script is that if I remove the rewrite, go directly to the file, it's fine. Well, all except for the placeholders for the links. :-P

Output validates to XHTML strict.
CSS validates to 2.1 without warnings.

As I've said, I've used this before, many times, open a template and output text/html . . . CSS has always linked fine. What can I be missing?

 

phranque




msg:4198903
 12:09 am on Sep 9, 2010 (gmt 0)

have you looked at the response headers?
perhaps your script and/or server is outputting multiple Content_type headers and the text/css one is being ignored.

rocknbil




msg:4198927
 1:15 am on Sep 9, 2010 (gmt 0)

[SOLVED]

DOH what a dork. :-P

RewriteRule ^pagedirectory\/([^/]*)\/*(.*) /cgi-bin/page-parser.cgi?d=$1&p=$2 [L]

The bolded means *everything*. Including CSS. Which was being output as text/html by the script (and necessarily, too . . . DOH!) What a maroon. :-)

I'd overlooked it because I wanted to capture requests for /directoryname/ and directoryname/index.html . . . was too tired to remember it would capture directoryame/css/oops.css too.

<facepalm x 1000>

phranque




msg:4199149
 8:01 am on Sep 9, 2010 (gmt 0)

how humiliating!
i don't think i've ever overlooked a greedy regular expression.
=8)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved