Welcome Guest, Not a member yet? Register   Sign In
"Resource interpreted as stylesheet but transferred with MIME type text/html"
#1

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

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

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?
#2

[eluser]cahva[/eluser]
So when you put http://d2.test/SMaLL/Assets/SMaLL.css in your browser url, it will show you the css?
#3

[eluser]Kenneth Allen[/eluser]
[quote author="cahva" date="1245982519"]So when you put http://d2.test/SMaLL/Assets/SMaLL.css in your browser url, it will show you the css?[/quote]
o, I get a 404 page error that seems to have been produced by CI. My routes file contains
Code:
$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?
#4

[eluser]Thorpe Obazee[/eluser]
Did you use htaccess?
#5

[eluser]slowgary[/eluser]
[quote author="Kenneth Allen" date="1246000447"]Could this be why the stylesheet is not being pulled in as well?[/quote]

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:
Code:
RewriteCond $1 !^(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.
#6

[eluser]Kenneth Allen[/eluser]
OK, I resolved the CSS issue by adding the assets folder the htaccess file, shown below.
Code:
RewriteEngine on
RewriteCond $1 !^(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?
#7

[eluser]TheFuzzy0ne[/eluser]
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.
#8

[eluser]Kenneth Allen[/eluser]
[quote author="TheFuzzy0ne" date="1246137106"]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.[/quote]
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?
#9

[eluser]TheFuzzy0ne[/eluser]
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:

Code:
$config['index_page'] = "";




Theme © iAndrew 2016 - Forum software by © MyBB