简体   繁体   English

找不到 style.css 的 GET 404 错误

[英]GET 404 error for style.css not found

I am currently working on codeigniter framework, in the view i added my custom 404 error's page.我目前正在研究codeigniter框架,在视图中我添加了我的自定义 404 错误页面。 But it is not loading the stylesheet from the folder errorpage/web/css/style.css.但它没有从文件夹 errorpage/web/css/style.css 加载样式表。 And i am getting an error in the browser's console GET : url/style.css 404(not found) (url is the address of my folder where my css file is)我在浏览器的控制台GET 中收到错误:url/style.css 404(not found) (url 是我的 css 文件所在文件夹的地址)

404 is a 'not found' error. 404 是“未找到”错误。 Meaning, the browser cannot find your style.css with the path it was given.意思是,浏览器无法通过给定的路径找到您的 style.css。 If it is working on some templates and not others, it is because you may have a different file structure for some templates, a sub-folder for example.如果它正在处理某些模板而不是其他模板,那是因为您可能对某些模板具有不同的文件结构,例如子文件夹。

A quick fix would be to make your style.css load from an absolute path一个快速的解决方法是让你的 style.css 从绝对路径加载

https://yourdomain.com/public/css/style.css

A better solution would be to traverse the directory to the css folder and then reference your style.css.更好的解决方案是将目录遍历到 css 文件夹,然后引用您的 style.css。

Learn about relative paths and find a solution that works for all templates.了解相对路径并找到适用于所有模板的解决方案。 The answer is likely to be something like:答案很可能是这样的:

/public/css/style.css

However, it could be something like:但是,它可能是这样的:

../public/css/style.css

Where goes back to one more previous directory.哪里又回到以前的目录。 More about absolute vs. relative paths http://www.coffeecup.com/help/articles/absolute-vs-relative-pathslinks/更多关于绝对路径和相对路径http://www.coffeecup.com/help/articles/absolute-vs-relative-pathslinks/

You can try replacing the contents of original 404 Page Not Found error page with your custom error page.您可以尝试用您的自定义错误页面替换原始 404 Page Not Found 错误页面的内容。 Make sure you doesn't change the name of that file or its location.确保您没有更改该文件的名称或其位置。

Hope it helps希望能帮助到你

变化<base href="/"><base href="./">从index.html的

In my case problem was in incorrect file premissions (should be 644).在我的情况下,问题在于不正确的文件权限(应该是 644)。 In some cases is also smart to consider clearing cache in cloudflare.在某些情况下,考虑清除 cloudflare 中的缓存也是明智之举。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM