unknown
unknown

Reputation: 55

My css works on my local xampp server and not on my website

I have a website. My css is not being applied to it. These files are exactly the same as the ones I have locally. These work on my own localhost. I use php in my css document so the file extension is .php

(my css document) main.php:

<?php
    header("Content-type: text/css; charset: utf-8");
?>

my index document calling in main.php:

<head>
    <meta charset="utf-8">
    <title>Chris Munroe</title>
    <link rel = "stylesheet" href = "css/normalize.css">
    <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
    <link rel = "stylesheet" href = "css/main.php">

</head>

If you click to my about page there is another css document specifically for that page. On the website, you will see, that it works fine. What is wrong here? Can you not mingle php with css? Does it matter where I use that header in my php/css document?

Upvotes: 1

Views: 195

Answers (2)

skv
skv

Reputation: 1803

As Dagon pointed even though you are setting the content type you need to do this to enforce it.
Place the CSS in a separate folder and then

Create a *.htaccess file in that folder and add the following:

AddHandler application/x-httpd-php .css

This should do the trick for you

Upvotes: 1

unknown
unknown

Reputation: 55

Wow. It was because the utf was lower case. That was it.

fix:

header("Content-type: text/css; charset: UTF-8");

You can check the website for yourself its all good now....

Upvotes: 2

Related Questions