Updated to Apache 2.4 and now my style sheets do not load

If it’s worth anything, leaving off the “lc” subdomain from the front of your domain nets me a css file. That could be totally extraneous and not useful info, but I just thought I’d toss it out there.

Yes, I’m 100% sure, because, as I’ve stated before, this site has existed for many years, and this issue only arose when I upgraded to Apache 2.4. I’ve coded all my sites the same way, storing my CSS in a folder named “CSS” and in the index.php file assigning the variable $Styles=(link rel=stylesheet code placed here). Then in my templates I “echo $Styles” (Can’t use angle brackets here because this forum seems to ignore anything in angle brackets).

more accurately, it tries to process it as HTML :wink: you can stick bits inside backticks to put it into a code block: `<this is some code>` (the backticks wont normally show up; they’re there for demonstrative purposes here.)

Again, if you go directly to the CSS file in your browser, what happens?

Probably because it’s connecting you to the live site, not the site in htdocs.

no, not the local file path, go to the URL the browser showed you: http://lc.kinsmanwebdesign.com/CSS/global.css

If you go to the local file path, you’re not going through the server layer.

(Edge has no concept that C:\Program Files\etc... is served by apache; so it just navigates the file system directly, and reads the file contents; we want to see what Apache is doing to your request for the file.)

1 Like

m_hutley’s method (above is a good one), but can you also try the following:

  • Open the devtools in Firefox (by pressing F12)
  • Open the Network tab
  • Reload the page using Ctrl + R
  • You should now see the two failed requests from above
  • Click on one of them and a new panel should open on the right of the screen
  • In this new panel you should see a Response tab
  • Click on the response tab and take a screenshot of what you see
  • Post the screenshot here

Looks like just text, doesn’t it?

Yes, but it proves that the server has found the file, and has returned its contents without a throwing a problem screen at you. So now we know its not:

  • A missing file
  • Permissions Issues
  • Going to show up as an error in the logs, because the server thinks it served the file correctly
  • Most serving issues

The browser has told you it saw a MIME type text/html on this file.

You said you added the type to Apache’s config, right? What line specifically did you add, and which ‘config file’ was it added to?

httpd.conf

I want to thank you all for helping me to try to solve this puzzle. I have spent hours (even today) searching the Web for some answers, even Apache Documentation. I have seen many suggestions, but none have worked yet. I know there must be an answer. This has me totally stumped! How can it find the file, yet not recognize that it’s a .css file?
By the way, hats off to Kevin Yank (is he still around?). I learned almost everything I know from his excellent book, “Build Your Own Database Driven Website, using PHP and MySQ,” and another Sitepoint book, “Designing Without Tables.” I also bought the book, “Begining PHP 5.3” by Matt Doyle.
I love learning, but this one has me really frustrated!

You’re welcome. It’s a bit frustrating we couldn’t get to the bottom of it.

I’m just curious why you didn’t follow up on my suggestion in posts #17 and #28 (same suggestion in each post).

For whatever reason your server is not behaving as it should and inspecting its response to the client would give us more information.

Also, it would be good to look in Apache’s logs to see what is going on there. This should tell you where to find them.

https://httpd.apache.org/docs/trunk/platform/windows.html

Here’s what I got when I clicked one of the failed requests, which I did post above:

It shows that Apache is finding the file, and there isn’t a “permissions” issue (as someone mentioned above).

I’ll explore the Apache logs this morning to see what I can find. Thanks for that link. Be back later. It’s 4:11 AM here now.

Thanks again, for your help.

Ya this is… very purplexing at this point. You’ve got the right configuration (assuming nowhere else in your configs has something for some reason set the type for css back to text/html)…

You have restarted the apache server since you put that line into the config, right? (Yes, i know that sounds like tech support level 1, but i’m running out of ideas here.)

Hi,

That’s not quite what I meant. In that screen shot it seems that you have opened the resource (which we have established exists) in the browser.

Here is an example using a random page on Wikipedia and the Firefox dev tools.

As you can see, I have highlighted one of the CSS files and clicked to the Response tab. In this case the file was transferred successfully, so it shows the contents of the file. I would be curious to know what the response is showing in your case (and also the request for that matter). It might not help us out much, but it would be worth having a look.

1 Like

Well, let me try again. I posted what I got the first time. Perhaps I didn’t do it right.
Okay, here it is. It took me some fooling around to get a screen that looks like you posted:


It’s showing us what we already knew, that the files are seen as html, not css.

Here’s what I get if I click on one of my css files:


If I click on “response” in the right panel, I get exactly what I posted above, the css file.

all requests have status 200. so they are ok

I find it weird that we are now seeing “9 requests 211.62 kB transferred”, not “8 requests 0 B transferred” as previously.

Well, the Font, “Awesome,” is showing twice there. I reloaded and did everything over:

It has 200, so the server thinks they’re okay. The browser disagrees, because it asked for a text/css file, and got a text/html response.
That said, this screen also shows that the server mime-typed the images as text/html as well. Something’s definitely wrong in the server’s mime-typing…it’s bouncing EVERYTHING as text/html…