前往:HTML找不到CSS档案

So i'm writing a web application in Golang. The html references a css file like so: <link href="/css/index.css"..., but the css file is never found!.

Here is the bummer though, i have a couple of css files and they are all in the same folder, and they all work!.

If i create another css file and name it index2.css and copy the contents of index.css into index2.css, this works perfectly, but for some reason, the name index.css does not work!

Also, when i go to the link http://localhost:8080/css/ this list all my css files. If i click on any of them, it opens up perfectly except index.css; i get a 404 not found.

This is really strange, any idea what could be the problem?

All files in css folder:

enter image description here

index.css not found:

enter image description here

<head>
    <title>Title</title>
    <link href="/css/index2.css" rel="stylesheet" type="text/css" media="screen"/>
    <link rel="icon" type="image/png" href="/images/img.png"/>
    <script src="/scripts/jquery.min.js"></script>
    <script src="/scripts/scroll.js"></script>
</head>

When i like to <link href="/css/index2.css" rel="stylesheet"... i can see the css style on my page. When i link to <link href="/css/index.css" rel="stylesheet"... i can't.

index.css exists in my folder:

enter image description here

EDIT

It works now. I think it was a permission issue. I deleted the old index.css and created a new one and it works now. Thanks for the help.

May be this problem is because of -

1.Temp file, try to find index.css~ file.If using Ubuntu then go to the css folder and press ctrl+H. then you will see the temp file if it is there.

2.May be path is not correct.

3.May be file got corrupted, try to delete and create new index.css

4.Provide your source code to debug your issue.

Did you mark the css folder as static in your server side script? Try running this code from your go web server and see if you could access those css files.

package main

import (
    "net/http"
)

func main() {
    http.Handle("/", http.FileServer(http.Dir("./web/content/css")))
    http.ListenAndServe(":8080", nil)
}

I'm not sure if I got your folder structure right, you might have to modify "./web/content/css".