0

I have a very basic webpage with two files, index.php and style.css

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>Test</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="style.css">
        <script language="JavaScript" type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    </head>
    <body>
        Example text
    </body>
</html>
body {
    text-align: center;
}

If I navigate to www.example.com this page loads correctly. WAMP automatically takes me to index.php. However if I navigate explicitly to www.example.com/index.php the css fails and everything reverts back to the default of being left-aligned.

EDIT: I originally blamed this on a GET variable but I have realised that's not the issue

retsek806
  • 11
  • 3
  • because your style file is defined relatively to current directory, so what you need to just add a forward slash to style href, like so : `/style.css`, now it will be relative to root directory – Serghei Leonenco Oct 26 '20 at 02:39
  • I have realised it's not the `GET` variable's fault, it is when `/index.php` is explicitly included that causes the css to fail. Sadly adding a forward slash before `style.css` didn't solve it – retsek806 Oct 26 '20 at 02:50
  • can you check in web debug panel, what error is showing there? – Serghei Leonenco Oct 26 '20 at 02:52
  • I get the error "The stylesheet http://localhost/testingbay/index.php/style.css was not loaded because its MIME type, "text/html", is not "text/css"." – retsek806 Oct 26 '20 at 02:54
  • add `type="text/css"` to your css link. Here is the relative info: https://stackoverflow.com/questions/2190459/the-stylesheet-was-not-loaded-because-its-mime-type-text-html-is-not-text-c – Serghei Leonenco Oct 26 '20 at 02:55
  • Thank-you, the `type="text/css"` was not necessary as I realised that I needed to write `/testingbay/style.css` because of how I am hosting this website. – retsek806 Oct 26 '20 at 03:04
  • You are welcome – Serghei Leonenco Oct 26 '20 at 03:05

0 Answers0