Forum Moderators: not2easy

Message Too Old, No Replies

CSS seen as mime type text/html

         

larry29936

10:20 pm on Jul 23, 2020 (gmt 0)

5+ Year Member Top Contributors Of The Month



My index.php works on my apache2 server but when I upload it to my webhost I'm getting the following errors:
Refused to apply style from 'https://example.com/css/index.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.


The top of my index.php follows:
<?php

$php_scripts = '../php/';
require $php_scripts . 'PDO_Connection_Select.php';
require $php_scripts . 'GetUserIpAddr.php';

{
$ip = GetUserIpAddr();
if (!$pdo = PDOConnect("foxclone_data")) {
exit;
}
{
$stmt = $pdo->prepare("INSERT INTO access (address) values (?)");
$stmt->execute([$ip]) ;
}
}
?>
<DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0">
<title>Foxclone backup and cloning utility</title>
<meta name="description" content= "FoxClone is a Linux based image backup, restore and clone tool using a simple point and click interface." />
<meta name="robots" content= "index, follow">

<link href="css/index.css" rel="stylesheet" />
<link href="css/navbar.css" rel="stylesheet" />

<!-- Favicon -->
<link rel="icon" href="fox.ico" />
</head>


Can someone provide some insight on ths?

not2easy

10:36 pm on Jul 23, 2020 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



The MIME type for css is not text/html, it is text/css and it should be included in the link as in:
 <link rel="stylesheet" type="text/css" media="screen" href="/css/index.css"> 

phranque

10:56 pm on Jul 23, 2020 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



i would examine the HTTP Response headers when requesting the .css file.

you might need to check the mod_mime directives in your configuration.
https://httpd.apache.org/docs/2.4/mod/mod_mime.html#addtype

larry29936

11:22 pm on Jul 23, 2020 (gmt 0)

5+ Year Member Top Contributors Of The Month



@not2easy - made the change to both links, index.css and navbar.css. Still getting the error on navbar.css.
@phranque - It works fine locally, just not on the webhost.

larry29936

11:33 pm on Jul 23, 2020 (gmt 0)

5+ Year Member Top Contributors Of The Month



@not2easy- looked at the error more closely. It's throwing the navbar error on the first line after the php section, <DOCTYPE html>

larry29936

12:19 am on Jul 24, 2020 (gmt 0)

5+ Year Member Top Contributors Of The Month



Stupid mistake on my part.....

Had <DOCTYPE html> instead of <!DOCTYPE html>. Thanks to everyone who replied.

tangor

4:49 am on Jul 24, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Those pesky little details!

Glad for the happy resolution!

And thanks for checking back with the result ... all too often others fail to do that, leaving the thread "open"...