EllisLab text mark
Advanced Search
     
“Resource interpreted as stylesheet but transferred with MIME type text/html”
Posted: 25 June 2009 11:45 AM
Joined: 2009-06-08
42 posts

I have a relatively simple page that refuses to use the specified CSS! I am developing on a Mac, and I have tested with Safari and Firefox and I get the same results. I finally chased the issue down to an entry in the Safari error console that I placed in the title for this entry.

The template file I am rendering looks like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
>
<
html>
    <
head>
        <
meta http-equiv="Content-type" content="text/html; charset=utf-8" />
        <
title><?php echo $page_title?></title>
        
<?php echo link_tag('Assets/SMaLL.css')."\n"?>
    
</head>
    <
body>
        <
div>
            
<?php echo $content "\n"?>
        
</div>
        <
div>
            <
p><br />Page rendered in {elapsed_time} seconds</p>
        </
div>
    </
body>
</
html

and the rendered page contains this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
>
<
html>
    <
head>
        <
meta http-equiv="Content-type" content="text/html; charset=utf-8" />
        <
title>SMaLL Administration</title>
        <
link  href="http://d2.test/SMaLL/Assets/SMaLL.css" rel="stylesheet" type="text/css" />
    </
head>
    <
body>
        <
div>
            <
h1>SMaLL Administration</h1>
        </
div>
        <
div>
            <
p><br />Page rendered in 0.1011 seconds</p>
        </
div>
    </
body>
</
html

And the file ~/Sites/D2TestSite/SMaLL/Assets/SMaLL.css does exist.

I have tried several things but I cannot see an error that would be causing this. Does anyone know what I need to do to resolve this?

 
Posted: 25 June 2009 06:15 PM   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2008-07-16
664 posts

So when you put http://d2.test/SMaLL/Assets/SMaLL.css in your browser url, it will show you the css?

 
Posted: 25 June 2009 11:14 PM   [ # 2 ]   [ Rating: 0 ]
Joined: 2009-06-08
42 posts
cahva - 25 June 2009 10:15 PM

So when you put http://d2.test/SMaLL/Assets/SMaLL.css in your browser url, it will show you the css?

o, I get a 404 page error that seems to have been produced by CI. My routes file contains

$route['admin'"admin";
$route['default_controller'"small"

and it looks like the errors/error_404.php file is being hit.

Could this be why the stylesheet is not being pulled in as well?

How do I get it to permit the URI for the style sheet through?

 
Posted: 25 June 2009 11:32 PM   [ # 3 ]   [ Rating: 0 ]
Joined: 2008-04-19
1153 posts

Did you use htaccess?

 Signature 

Thorpe Obazee

 
Posted: 26 June 2009 12:39 AM   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2009-03-21
680 posts
Kenneth Allen - 26 June 2009 03:14 AM

Could this be why the stylesheet is not being pulled in as well?

Yes.  The browser requests the file just like you do when you visit it directly, therefore if you cannot visit the file directly than the browser cannot find it.

It’s likely an htaccess issue.  You should post your htaccess so someone smarter than me can scrutinize it.  Usually there’s a line that denotes folders that should not get rewritten, something like this:

RewriteCond $!^(index\.php|assets|images|css|js|robots\.txt|favicon\.ico

That line should contain your ‘SMaLL’ and any other folders that you don’t want rewritten.  As a side note, I loathe the fact that you’re using 733T style CaSE in your path, what’s the purpose?  I wonder if that could be causing issues as well.

 
Posted: 27 June 2009 12:57 PM   [ # 5 ]   [ Rating: 0 ]
Joined: 2009-06-08
42 posts

OK, I resolved the CSS issue by adding the assets folder the htaccess file, shown below.

RewriteEngine on
RewriteCond 
$!^(index\.php|assets)
RewriteRule ^(.*)$ /SMaLL/index.php/$1 [L] 

This also removes the need for me to enter “index.php” in the URI, but when I use a redirect() call, the URI has the “index.php” part back again.

How do I convince CI not to add in the “index.php” when it builds the URI for redirects?

 
Posted: 27 June 2009 01:11 PM   [ # 6 ]   [ Rating: 0 ]
Avatar
Joined: 2008-04-25
4956 posts

I don’t think you’re htaccess will work as expected. You shouldn’t need to specify a directory, since the htaccess file should be in the root of that directory anyway.

 Signature 

http://www.phptherightway.com

Remember the 8 Ps: Perfect Planning and Prior Preparation Prevents Piss-Poor Performance.

 
Posted: 27 June 2009 01:29 PM   [ # 7 ]   [ Rating: 0 ]
Joined: 2009-06-08
42 posts
TheFuzzy0ne - 27 June 2009 05:11 PM

I don’t think you’re htaccess will work as expected. You shouldn’t need to specify a directory, since the htaccess file should be in the root of that directory anyway.

My CI application is actually in a folder within an existing site. On my development system the UIR is “d2.test”, and I access my CI application with “d2.test/SMaLL” and the admin controller with “d2.test/SMaLL/admin”, which works fine thanks to the htaccess file in the SMaLL folder.

But if one of the controller steps executes a call such as redirect(‘admin’), the resulting URI is “d2.test/SMaLL/index.php/admin” instead of the preferred “d2.test/SMaLL/admin”. How do I convince the redirect() calls to also omit the “index.php/” part of the URI, since it is not required?

 
Posted: 27 June 2009 03:49 PM   [ # 8 ]   [ Rating: 0 ]
Avatar
Joined: 2008-04-25
4956 posts

Sorry, I don’t know what happened. I seem to have totally avoided ansering your question in your previous post.

When CodeIgniter redirects, it shouldn’t add index.php if you have removed set index_page to an empty string, in your config.php file:

$config['index_page'""
 Signature 

http://www.phptherightway.com

Remember the 8 Ps: Perfect Planning and Prior Preparation Prevents Piss-Poor Performance.